Re: regex line by line over file

2014-03-27 Thread James Smith
On Thursday, March 27, 2014 1:32:03 AM UTC-4, Steven D'Aprano wrote: - are you mistaken about the content of the file? I can't help you with the first. But the second: try running this: # line2 and pat as defined above filename = sys.argv[1] with open(filename) as f: for line in f:

Re: regex line by line over file

2014-03-27 Thread James Smith
On Thursday, March 27, 2014 9:41:55 AM UTC-4, James Smith wrote: (134, False, '\' SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:Log Collection In Progress,NONE:170035-6364-1048,:YEAR=2014,MODE=NONE\\r\\n\'') Is the \r\n on the end of the line screwing it up? Got it.

Re: regex line by line over file

2014-03-27 Thread Peter Pearson
On Thu, 27 Mar 2014 06:41:55 -0700 (PDT), James Smith wrote: On Thursday, March 27, 2014 1:32:03 AM UTC-4, Steven D'Aprano wrote: - are you mistaken about the content of the file? I can't help you with the first. But the second: try running this: # line2 and pat as defined above filename

regex line by line over file

2014-03-26 Thread James Smith
I can't get this to work. It runs but there is no output when I try it on a file. #!/usr/bin/python import os import sys import re from datetime import datetime #logDir = '/nfs/projects/equinox/platformTools/RTLG/RTLG_logs'; #os.chdir( logDir ); programName = sys.argv[0] fileName =

Re: regex line by line over file

2014-03-26 Thread Chris Angelico
On Thu, Mar 27, 2014 at 2:23 PM, James Smith bjloc...@lockie.ca wrote: re.M p = re.compile('^\s*\SHELF-.*,SC,.*,:\\\Log Collection In Progress\\\') If you're expecting this to be parsed as a multiline regex, it won't be. Probing re.M doesn't do anything on its own; you have to pass it as an

Re: regex line by line over file

2014-03-26 Thread James Smith
On Wednesday, March 26, 2014 11:23:29 PM UTC-4, James Smith wrote: I can't get this to work. It runs but there is no output when I try it on a file. #!/usr/bin/python import os import sys import re from datetime import datetime #logDir =

Re: regex line by line over file

2014-03-26 Thread Rustom Mody
On Thursday, March 27, 2014 8:53:29 AM UTC+5:30, James Smith wrote: I can't get this to work. It runs but there is no output when I try it on a file. #!/usr/bin/python import os import sys import re from datetime import datetime #logDir =

Re: regex line by line over file

2014-03-26 Thread Chris Angelico
On Thu, Mar 27, 2014 at 3:14 PM, James Smith bjloc...@lockie.ca wrote: I tried the re.M in the compile and that didn't help. Okay. Try printing out the repr of the line at the point where you have the commented-out write to stdout. That might tell you if there's some other difference. At that

Re: regex line by line over file

2014-03-26 Thread Steven D'Aprano
On Wed, 26 Mar 2014 20:23:29 -0700, James Smith wrote: I can't get this to work. It runs but there is no output when I try it on a file. Simplify, simplify, simplify. Either you will find the problem, or you will find the simplest example that demonstrates the problem. In this case, the