Page 1 of 1

Read file-> extract the sentence to extract word

Posted: 27 Feb 2015 12:03
by joecepy
I have following text
10444 [] INFO 2015-02-25 00:57:59.040 TM1.Process Process QueBIT Sample - Turn On Cube Logging executed by chore Admin.Enable.Cube.Logging.30min.Interval
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project_lob_history' depends on cube '}ElementSecurity_project_lob_history'.
10444 [] INFO 2015-02-25 00:57:59.040 TM1.Process Process "QueBIT Sample - Turn On Cube Logging": finished executing normally, elapsed time 0.00 seconds
10444 [] INFO 2015-02-25 00:57:59.040 TM1.Chore Chore "Admin.Enable.Cube.Logging.30min.Interval" time = 0.00 seconds
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project' depends on cube 'CPX_DETAIL2'.
10444 [] INFO 2015-02-25 00:57:59.040 TM1.Chore Chore "Admin.Enable.Cube.Logging.30min.Interval" finished executing
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Chore Chore "Admin.Add.Cube.Dependencies@200AM" executed by scheduler
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Process Process Admin.Add.Cube.Dependencies executed by chore Admin.Add.Cube.Dependencies@200AM
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project' depends on cube '}ElementSecurity_project'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_}Groups' depends on cube '}ElementSecurity_project'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project_lob_history' depends on cube '}ElementSecurity_project_lob_history'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_}Groups' depends on cube '}ElementSecurity_project_lob_history'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project' depends on cube 'CPX_DETAIL'.


I need to get the line of text that contains TM1.Cube.Dependency and within that sentence I need to grab the UNIQUE items that are in single quotes.

So I'd retrieve the sentence:
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project_lob_history' depends on cube '}ElementSecurity_project_lob_history'.
and get '}ElementAttributes_project_lob_history' and '}ElementSecurity_project_lob_history'
continue to process the file but if I see the same items '}ElementAttributes_project_lob_history' and '}ElementSecurity_project_lob_history' it would ignore and continue to next. Of course this is done in batch only no 3rd party tools.

thanks in advanced.

Re: Read file-> extract the sentence to extract word

Posted: 27 Feb 2015 12:33
by foxidrive
Can you clarify your question?

Given the data you provided, what do you want in the output text file?

Re: Read file-> extract the sentence to extract word

Posted: 27 Feb 2015 12:40
by Squashman
Sounds like a job for JREPL but you could do it with a simple FOR /F and then just dedupe the output file.

Re: Read file-> extract the sentence to extract word

Posted: 27 Feb 2015 12:43
by joecepy
the items in a single quote so
'}ElementAttributes_}Groups' '}ElementSecurity_project'
'}ElementAttributes_project_lob_history' '}ElementSecurity_project_lob_history'
'}ElementAttributes_}Groups' '}ElementSecurity_project_lob_history'
'}ElementAttributes_project' 'CPX_DETAIL'

but it has to be unique. If it finds '}ElementAttributes_}Groups' '}ElementSecurity_project' again it would ignore that.

I can't delmit by ' because there are other line of sentence that contains ' quoted items. That's why I'm looking for the line of sentence that contains TM1.Cube.Dependency.

Re: Read file-> extract the sentence to extract word

Posted: 27 Feb 2015 12:44
by Squashman
Little easier to visualize the data when it is in sorted order. Looks like a LOG file. How did the output get out of order?
10444 [] INFO 2015-02-25 00:57:59.040 TM1.Chore Chore "Admin.Enable.Cube.Logging.30min.Interval" finished executing
10444 [] INFO 2015-02-25 00:57:59.040 TM1.Chore Chore "Admin.Enable.Cube.Logging.30min.Interval" time = 0.00 seconds
10444 [] INFO 2015-02-25 00:57:59.040 TM1.Process Process "QueBIT Sample - Turn On Cube Logging": finished executing normally, elapsed time 0.00 seconds
10444 [] INFO 2015-02-25 00:57:59.040 TM1.Process Process QueBIT Sample - Turn On Cube Logging executed by chore Admin.Enable.Cube.Logging.30min.Interval
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Chore Chore "Admin.Add.Cube.Dependencies@200AM" executed by scheduler
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project' depends on cube 'CPX_DETAIL'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project' depends on cube 'CPX_DETAIL2'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project' depends on cube '}ElementSecurity_project'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project_lob_history' depends on cube '}ElementSecurity_project_lob_history'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_project_lob_history' depends on cube '}ElementSecurity_project_lob_history'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_}Groups' depends on cube '}ElementSecurity_project'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Cube.Dependency Adding cube dependency: Cube '}ElementAttributes_}Groups' depends on cube '}ElementSecurity_project_lob_history'.
10456 [] INFO 2015-02-25 01:00:29.859 TM1.Process Process Admin.Add.Cube.Dependencies executed by chore Admin.Add.Cube.Dependencies@200AM

Re: Read file-> extract the sentence to extract word

Posted: 27 Feb 2015 12:48
by joecepy
I copied and pasted few lines to show there are duplicate items

Re: Read file-> extract the sentence to extract word

Posted: 27 Feb 2015 12:49
by Squashman
joecepy wrote:but it has to be unique. If it finds '}ElementAttributes_}Groups' '}ElementSecurity_project' again it would ignore that.

That is not a duplicate in your EXAMPLE!
This is the only duplicate in your example.
ElementAttributes_project_lob_history' '}ElementSecurity_project_lob_history'

Re: Read file-> extract the sentence to extract word

Posted: 27 Feb 2015 12:57
by Squashman
joecepy wrote:I can't delmit by ' because there are other line of sentence that contains ' quoted items. That's why I'm looking for the line of sentence that contains TM1.Cube.Dependency.

What do you mean you can't delimit?

Code: Select all

@echo off
FOR /F "tokens=2,4 delims='" %%G IN ('type input.txt ^|find "TM1.Cube.Dependency"') DO echo %%G %%H
pause

Output

Code: Select all

}ElementAttributes_project CPX_DETAIL
}ElementAttributes_project CPX_DETAIL2
}ElementAttributes_project }ElementSecurity_project
}ElementAttributes_project_lob_history }ElementSecurity_project_lob_history
}ElementAttributes_project_lob_history }ElementSecurity_project_lob_history
}ElementAttributes_}Groups }ElementSecurity_project
}ElementAttributes_}Groups }ElementSecurity_project_lob_history
Press any key to continue . . .

This gets you part way there. Now you can just run a 2nd set of code to dedupe the output.

Re: Read file-> extract the sentence to extract word

Posted: 27 Feb 2015 12:58
by joecepy
much appreciated!