regex line by line over file
bjlockie at lockie.ca
Thu Mar 27 04:23:29 CET 2014
I can't get this to work.
It runs but there is no output when I try it on a file.
from datetime import datetime
#logDir = '/nfs/projects/equinox/platformTools/RTLG/RTLG_logs';
#os.chdir( logDir );
programName = sys.argv
fileName = sys.argv
#pattern = re.compile('\s*\\"SHELF-.*,SC,.*,:\\"Log Collection In Progress\\"')
p = re.compile('^\s*\"SHELF-.*,SC,.*,:\\\"Log Collection In Progress\\\"')
l = ' "SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\"Log Collection In Progress\",NONE:1700000035-6364-1048,:YEAR=2014,MODE=NONE"'
# this works :-)
m = p.match( l )
print( l )
# this doesn't match anything (or the if doesn't work) :-(
with open(fileName) as f:
for line in f:
# debug code (print the line without adding a linefeed)
# sys.stdout.write( line )
The test file just has one line:
"SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:\"Log Collection In Progress\",NONE:1700000035-6364-1048,:YEAR=2014,MODE=NONE"
More information about the Python-list