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 from "ethtool" command

2011-11-02 Thread Jean-Michel Pichavant
extraspecialbitter wrote: I'm still trying to write that seemingly simple Python script to print out network interfaces (as found in the "ifconfig -a" command) and their speed ("ethtool "). The idea is to loop for each interface and print out its speed. I'm looping correctly, but have some issu

Re: parsing text from "ethtool" command

2011-11-02 Thread extraspecialbitter
On Nov 1, 7:35 pm, Ian Kelly wrote: > On Tue, Nov 1, 2011 at 5:19 PM, Miki Tebeka wrote: > > In my box, there are some spaces (tabs?) before "Speed". IMO > > re.search("Speed", line) will be a more robust. > > Or simply: > > if "Speed" in line: > > There is no need for a regular expression here.

Re: parsing text from "ethtool" command

2011-11-01 Thread Ian Kelly
On Tue, Nov 1, 2011 at 5:19 PM, Miki Tebeka wrote: > In my box, there are some spaces (tabs?) before "Speed". IMO > re.search("Speed", line) will be a more robust. Or simply: if "Speed" in line: There is no need for a regular expression here. This would also work and be a bit more discriminat

Re: parsing text from "ethtool" command

2011-11-01 Thread Miki Tebeka
In my box, there are some spaces (tabs?) before "Speed". IMO re.search("Speed", line) will be a more robust. -- http://mail.python.org/mailman/listinfo/python-list

parsing text from "ethtool" command

2011-11-01 Thread extraspecialbitter
I'm still trying to write that seemingly simple Python script to print out network interfaces (as found in the "ifconfig -a" command) and their speed ("ethtool "). The idea is to loop for each interface and print out its speed. I'm looping correctly, but have some issues parsing the output for al

Re: Parsing text

2009-05-07 Thread Suraj Barkale
iainemsley googlemail.com> writes: > > Hi, > I'm trying to write a fairly basic text parser to split up scenes and > acts in plays to put them into XML. I've managed to get the text split > into the blocks of scenes and acts and returned correctly but I'm > trying to refine this and get the rele

Re: Parsing text

2009-05-06 Thread C or L Smith
> Hi, > I'm trying to write a fairly basic text parser to split up scenes and > acts in plays to put them into XML. I've managed to get the text split > into the blocks of scenes and acts and returned correctly but I'm > trying to refine this and get the relevant scene number when the split > is ma

Re: Parsing text

2009-05-06 Thread Rhodri James
On Wed, 06 May 2009 19:32:28 +0100, iainemsley wrote: Hi, I'm trying to write a fairly basic text parser to split up scenes and acts in plays to put them into XML. I've managed to get the text split into the blocks of scenes and acts and returned correctly but I'm trying to refine this and ge

Re: Parsing text

2009-05-06 Thread Stefan Behnel
iainemsley wrote: > for scene in text.split('Scene'): > num = re.compile("^\s\[0-9, i{1,4}, v]", re.I) > textNum = num.match(scene) Not related to your problem, but to your code - I'd write this as follows: match_scene_num = re.compile("^\s\[0-9, i{1,4}, v]", re.I).match

Re: Parsing text

2009-05-06 Thread Tim Chase
I'm trying to write a fairly basic text parser to split up scenes and acts in plays to put them into XML. I've managed to get the text split into the blocks of scenes and acts and returned correctly but I'm trying to refine this and get the relevant scene number when the split is made but I keep g

Re: Parsing text

2009-05-06 Thread MRAB
iainemsley wrote: Hi, I'm trying to write a fairly basic text parser to split up scenes and acts in plays to put them into XML. I've managed to get the text split into the blocks of scenes and acts and returned correctly but I'm trying to refine this and get the relevant scene number when the spl

Re: Parsing text

2009-05-06 Thread Scott David Daniels
iainemsley wrote: Hi, I'm trying to write a fairly basic text parser to split up scenes and acts in plays to put them into XML. I've managed to get the text split into the blocks of scenes and acts and returned correctly but I'm trying to refine this and get the relevant scene number when the spl

Re: Parsing text

2009-05-06 Thread Shawn Milochik
On Wed, May 6, 2009 at 2:32 PM, iainemsley wrote: > Hi, > I'm trying to write a fairly basic text parser to split up scenes and > acts in plays to put them into XML. I've managed to get the text split > into the blocks of scenes and acts and returned correctly but I'm > trying to refine this and g

Parsing text

2009-05-06 Thread iainemsley
Hi, I'm trying to write a fairly basic text parser to split up scenes and acts in plays to put them into XML. I've managed to get the text split into the blocks of scenes and acts and returned correctly but I'm trying to refine this and get the relevant scene number when the split is made but I kee

Re: parsing text from a file

2009-01-30 Thread John Machin
On Jan 30, 7:39 pm, Tim Golden wrote: > Wes James wrote: > > If I read a windows registry file with a line like this: > > > "{C15039B5-C47C-47BD-A698-A462F4148F52}"="v2.0|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Public|App=C:\\Program > > Files\\LANDesk\\LDClient\\tmcsvc.exe|Name=LANDesk

Re: parsing text from a file

2009-01-30 Thread Tim Golden
Wes James wrote: If I read a windows registry file with a line like this: "{C15039B5-C47C-47BD-A698-A462F4148F52}"="v2.0|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Public|App=C:\\Program Files\\LANDesk\\LDClient\\tmcsvc.exe|Name=LANDesk Targeted Multicast|Edge=FALSE|" Watch out. .reg

Re: parsing text from a file

2009-01-29 Thread MRAB
Wes James wrote: If I read a windows registry file with a line like this: "{C15039B5-C47C-47BD-A698-A462F4148F52}"="v2.0|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Public|App=C:\\Program Files\\LANDesk\\LDClient\\tmcsvc.exe|Name=LANDesk Targeted Multicast|Edge=FALSE|" with this code: f

Re: parsing text from a file

2009-01-29 Thread Tim Chase
if s.find('LANDesk') <0: is True for a line which doesn't contain "LANDesk"; if you want the opposite, try if s.find('LANDesk') >-1: Or more pythonically, just use if 'LANDesk' in s: -tkc -- http://mail.python.org/mailman/listinfo/python-list

Re: parsing text from a file

2009-01-29 Thread John Machin
On Jan 30, 8:54 am, Wes James wrote: > If I read a windows registry file with a line like this: > > "{C15039B5-C47C-47BD-A698-A462F4148F52}"="v2.0|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Public|App=C:\\Program > Files\\LANDesk\\LDClient\\tmcsvc.exe|Name=LANDesk Targeted > Multicast|Edge

Re: parsing text from a file

2009-01-29 Thread Vlastimil Brom
2009/1/29 Wes James : > If I read a windows registry file with a line like this: > ... > > with this code: > > f=open('fwrules.reg2.txt') > > for s in f: > if s.find('LANDesk') <0: >print s, > > > LANDesk is not found. > > how do I find LANDesk in a string like this. is the "\\" messing thing

parsing text from a file

2009-01-29 Thread Wes James
If I read a windows registry file with a line like this: "{C15039B5-C47C-47BD-A698-A462F4148F52}"="v2.0|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Public|App=C:\\Program Files\\LANDesk\\LDClient\\tmcsvc.exe|Name=LANDesk Targeted Multicast|Edge=FALSE|" with this code: f=open('fwrules.reg2

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(

Re: parsing text in blocks and line too

2007-04-12 Thread James Stroud
A.T.Hofkamp wrote: > On 2007-04-12, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> Goodmorning people :) >> I have just started to learn this language and i have a logical >> problem. >> I need to write a program to parse various file of text. >> Here two sample: >> >> --- >> trial tex

Re: parsing text in blocks and line too

2007-04-12 Thread A.T.Hofkamp
On 2007-04-12, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Goodmorning people :) > I have just started to learn this language and i have a logical > problem. > I need to write a program to parse various file of text. > Here two sample: > > --- > trial text bla bla bla bla error >

parsing text in blocks and line too

2007-04-12 Thread flyzone
Goodmorning people :) I have just started to learn this language and i have a logical problem. I need to write a program to parse various file of text. Here two sample: --- trial text bla bla bla bla error bla bla bla bla bla bla bla bla on more lines trial text bla bla bla

Re: Parsing text

2005-12-20 Thread Bengt Richter
On 20 Dec 2005 08:06:39 -0800, "sicvic" <[EMAIL PROTECTED]> wrote: >Not homework...not even in school (do any universities even teach >classes using python?). Just not a programmer. Anyways I should >probably be more clear about what I'm trying to do. Ok, not homework. > >Since I cant show the ac

Re: Parsing text

2005-12-20 Thread sicvic
Thank you everyone!!! I got a lot more information then I expected. You guys got my brain thinking in the right direction and starting to like programming. You've got a great community here. Keep it up. Thanks, Victor -- http://mail.python.org/mailman/listinfo/python-list

Re: Parsing text

2005-12-20 Thread Scott David Daniels
sicvic wrote: > Not homework...not even in school (do any universities even teach > classes using python?). Yup, at least 6, and 20 wouldn't surprise me. > The code I currently have looks something like this: > ... > f = open(sys.argv[1]) #opens output file > #loop that goes through all lines and

Re: Parsing text

2005-12-20 Thread Gerard Flanagan
sicvic wrote: > Since I cant show the actual output file lets say I had an output file > that looked like this: > > a b Person: Jimmy > Current Location: Denver It may be the output of another process but it's the input file as far as the parsing code is concerned. The code below gives t

Re: Parsing text

2005-12-20 Thread rzed
"sicvic" <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]: > Not homework...not even in school (do any universities even > teach classes using python?). Just not a programmer. Anyways I > should probably be more clear about what I'm trying to do. > > Since I cant show the actual output file l

Re: Parsing text

2005-12-20 Thread sicvic
Not homework...not even in school (do any universities even teach classes using python?). Just not a programmer. Anyways I should probably be more clear about what I'm trying to do. Since I cant show the actual output file lets say I had an output file that looked like this: a b Person: J

Re: Parsing text

2005-12-20 Thread Bengt Richter
On 19 Dec 2005 15:15:10 -0800, "sicvic" <[EMAIL PROTECTED]> wrote: >I was wondering if theres a way where python can read through the lines >of a text file searching for a key phrase then writing that line and >all lines following it up to a certain point, such as until it sees a >string of "-

Re: Parsing text

2005-12-19 Thread Noah
sicvic wrote: > I was wondering if theres a way where python can read through the lines > of a text file searching for a key phrase then writing that line and > all lines following it up to a certain point, such as until it sees a > string of "-" >... > Thanks, > Victor You did

Re: Parsing text

2005-12-19 Thread Peter Hansen
sicvic wrote: > I was wondering if theres a way where python can read through the lines > of a text file searching for a key phrase then writing that line and > all lines following it up to a certain point, such as until it sees a > string of "-" > > Right now I can only have p

Parsing text

2005-12-19 Thread sicvic
I was wondering if theres a way where python can read through the lines of a text file searching for a key phrase then writing that line and all lines following it up to a certain point, such as until it sees a string of "-" Right now I can only have python write just the line

Re: Parsing text into dates?

2005-05-17 Thread John Machin
On Tue, 17 May 2005 16:44:12 -0500, Mike Meyer <[EMAIL PROTECTED]> wrote: >"Thomas W" <[EMAIL PROTECTED]> writes: > >> I'm developing a web-application where the user sometimes has to enter >> dates in plain text, allthough a format may be provided to give clues. >> On the server side this piece o

Re: Parsing text into dates?

2005-05-17 Thread Mike Meyer
"Thomas W" <[EMAIL PROTECTED]> writes: > I'm developing a web-application where the user sometimes has to enter > dates in plain text, allthough a format may be provided to give clues. > On the server side this piece of text has to be parsed into a datetime > python-object. Does anybody have any p

Re: Parsing text into dates?

2005-05-16 Thread gene . tani
The beautiful brand new cookbook2 has "Fuzzy parsing of Dates" using dateutil.parser, which you run once you have a decent guess at locale (page 127 of cookbook) John Roth wrote: > "Thomas W" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I'm developing a web-application where t

Re: Parsing text into dates?

2005-05-16 Thread John Roth
"Thomas W" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm developing a web-application where the user sometimes has to enter > dates in plain text, allthough a format may be provided to give clues. > On the server side this piece of text has to be parsed into a datetime > python

Re: Parsing text into dates?

2005-05-16 Thread George Sakkis
"John Machin" <[EMAIL PROTECTED]> wrote: > On 16 May 2005 17:51:31 -0700, "George Sakkis" <[EMAIL PROTECTED]> > wrote: > > > >#=== > > > >def parseDateTime(string, USA=False, implyCurrentDate=False, > > yearHeuristic=_20thcentury

Re: Parsing text into dates?

2005-05-16 Thread John Machin
On 16 May 2005 17:51:31 -0700, "George Sakkis" <[EMAIL PROTECTED]> wrote: >#=== > >def parseDateTime(string, USA=False, implyCurrentDate=False, > yearHeuristic=_20thcenturyHeuristic): >'''Tries to parse a string as a valid d

Re: Parsing text into dates?

2005-05-16 Thread George Sakkis
"Thomas W" wrote: > I'm developing a web-application where the user sometimes has to enter > dates in plain text, allthough a format may be provided to give clues. > On the server side this piece of text has to be parsed into a datetime > python-object. Does anybody have any pointers on this? > >

Re: Parsing text into dates?

2005-05-16 Thread Peter Hansen
John Machin wrote: > If this application is being deployed from a central server where the > users can be worldwide, you have two options: > > (a) try to work out somehow what the user's locale is, and then work > with dates in the legacy format "appropriate" to the locale. And this inevitably sc

Re: Parsing text into dates?

2005-05-16 Thread John Machin
On 16 May 2005 13:59:31 -0700, "Thomas W" <[EMAIL PROTECTED]> wrote: >I'm developing a web-application where the user sometimes has to enter >dates in plain text, allthough a format may be provided to give clues. >On the server side this piece of text has to be parsed into a datetime >python-objec

Parsing text into dates?

2005-05-16 Thread Thomas W
I'm developing a web-application where the user sometimes has to enter dates in plain text, allthough a format may be provided to give clues. On the server side this piece of text has to be parsed into a datetime python-object. Does anybody have any pointers on this? Besides the actual parsing, my