Re: Parsing Text file

2013-07-02 Thread Denis McMahon
On Tue, 02 Jul 2013 13:28:33 -0700, sas429s wrote: > Ok here is a snippet of the text file I have: > I hope this helps.. > . > Thanks for your help ok ... so you need to figure out how best to distinguish the filename, then loop through the file, remember each filename as you find it, and w

Re: Parsing Text file

2013-07-02 Thread Joshua Landau
On 2 July 2013 21:28, wrote: > Here I am looking for the line that contains: "WORK_MODE_MASK", I want to > print that line as well as the file name above it: > config/meal/governor_mode_config.h > or config/meal/components/source/ceal_PackD_kso_aic_core_config.h. > > SO the output should be som

Re: Parsing Text file

2013-07-02 Thread sas429s
Ok here is a snippet of the text file I have: config/meal/governor_mode_config.h #define GOVERNOR_MODE_TASK_RATE SSS_TID_0015MSEC #define GOVERNOR_MODE_WORK_MODE_MASK(CEAL_MODE_WORK_MASK_GEAR| \ CEAL_MODE_WORK_MASK_PARK_BRAKE | \

Re: Parsing Text file

2013-07-02 Thread Joshua Landau
On 2 July 2013 20:50, Tobiah wrote: > How do we know whether we have Sometext? > If it's really just a literal 'Sometext', then > just print that when you hit maskit. > > Otherwise: > > > for line in open('file.txt').readlines(): > > if is_sometext(line): > memory = line >

Re: Parsing Text file

2013-07-02 Thread Neil Cerutti
On 2013-07-02, Tobiah wrote: > On 07/02/2013 12:30 PM, sas4...@gmail.com wrote: >> Somemore can be anything for instance: >> >> Sometext >> mail >> maskit >> >> Sometext >> rupee >> dollar >> maskit >> >> and so on.. >> >> Is there a way I can achieve this? > > How do we know whether we have Somet

Re: Parsing Text file

2013-07-02 Thread Tobiah
On 07/02/2013 12:30 PM, sas4...@gmail.com wrote: Somemore can be anything for instance: Sometext mail maskit Sometext rupee dollar maskit and so on.. Is there a way I can achieve this? How do we know whether we have Sometext? If it's really just a literal 'Sometext', then just print that wh

Re: Parsing Text file

2013-07-02 Thread sas429s
Somemore can be anything for instance: Sometext mail maskit Sometext rupee dollar maskit and so on.. Is there a way I can achieve this? On Tuesday, July 2, 2013 2:24:26 PM UTC-5, Neil Cerutti wrote: > On 2013-07-02, sas4...@gmail.com wrote: > > > I have a text file like this: > > > > > > S

Re: Parsing Text file

2013-07-02 Thread Neil Cerutti
On 2013-07-02, sas4...@gmail.com wrote: > I have a text file like this: > > Sometext > Somemore > Somemore > maskit > > Sometext > Somemore > Somemore > Somemore > maskit > > Sometext > Somemore > maskit > > I want to search for the string maskit in this file and also > need to print Sometext abov

Parsing Text file

2013-07-02 Thread sas429s
I have a text file like this: Sometext Somemore Somemore maskit Sometext Somemore Somemore Somemore maskit Sometext Somemore maskit I want to search for the string maskit in this file and also need to print Sometext above it..SOmetext location can vary as you can see above. In the first insta

Re: Parsing text file with #include and #define directives

2008-04-25 Thread python
Arnaud, Wow!!! That's beautiful. Thank you very much! Malcolm I think it's straightforward enough to be dealt with simply. Here is a solution that doesn't handle errors but should work with well-formed input and handles recursive expansions. expand(filename) returns an iterator over expanded

Re: Parsing text file with #include and #define directives

2008-04-24 Thread Arnaud Delobelle
[EMAIL PROTECTED] writes: > I'm parsing a text file for a proprietary product that has the following > 2 directives: > > #include > #define > > Defined constants are referenced via <#name#> syntax. > > I'm looking for a single text stream that results from processing a file > containing these d

Parsing text file with #include and #define directives

2008-04-24 Thread python
I'm parsing a text file for a proprietary product that has the following 2 directives: #include #define Defined constants are referenced via <#name#> syntax. I'm looking for a single text stream that results from processing a file containing these directives. Even better would be an iterator(