Re: extract substring by regex from a text file

2010-04-17 Thread Alessio
On Apr 17, 11:05 am, Peter Otten <__pete...@web.de> wrote: > > Just in case you didn't know: > >     for line in instream: >         ... > > looks better, uses less memory, and may be a tad faster than > >     for line in instream.readlines(): >         ... > > Peter Thanks for your suggestions, t

Re: extract substring by regex from a text file

2010-04-17 Thread Peter Otten
Alessio wrote: > I used readlines() to read my text file, then with a for cicle I > extract line by line the substrings I need by regular expressions Just in case you didn't know: for line in instream: ... looks better, uses less memory, and may be a tad faster than for line in

Re: extract substring by regex from a text file

2010-04-17 Thread Stefan Behnel
Alessio, 17.04.2010 10:19: I used readlines() to read my text file, then with a for cicle I extract line by line the substrings I need by regular expressions (re.findall()) Note that it's usually more efficient to just run the for-loop over the file object, rather than using readlines() first.

Re: extract substring by regex from a text file

2010-04-17 Thread Alessio
On Apr 15, 3:25 pm, Neil Cerutti wrote: > On 2010-04-15, Alessio wrote: > > > Hi, > > > I'm facing the problem in the subject: > > - I have a text file that I need to parse for producing a specifical Thank you, I forgot to say that I already solved. I used readlines() to read my text file, then w

Re: extract substring by regex from a text file

2010-04-15 Thread Neil Cerutti
On 2010-04-15, Alessio wrote: > Hi, > > I'm facing the problem in the subject: > - I have a text file that I need to parse for producing a specifical > string (Json like) extracting some information (substring) in it; > - I created regural expressions capable to locate these substrings in > my txt

extract substring by regex from a text file

2010-04-15 Thread Alessio
Hi, I'm facing the problem in the subject: - I have a text file that I need to parse for producing a specifical string (Json like) extracting some information (substring) in it; - I created regural expressions capable to locate these substrings in my txt file; now I don't know how to continue. Wh