I am writing a small python script to collect some data from a database, the only problem is when I export the data as XML from mysql, it includes the \ b character in the XML file. I wrote the code to remove it, but then I realized that I did not need to do this processing every time, so I put it in a method and call it. I find \ b in the XML file, only now the regular expression does not match, even though I know that \ b is.
that's what I'm doing:
The main program:
'''Program should start here'''
for line in xml_file:
p = re.compile("\b")
if(p.match(line)):
print p.match(line)
processing = True
break
if(processing):
print "preprocess"
preprocess(xml_file)
Pretreatment Method:
def preprocess(file):
print "in preprocess"
lines = []
for line in xml_file:
lines.append(re.sub("\b", "", line))
xml_file.seek(0);
for line in lines:
xml_file.write(line);
xml_file.truncate()
Any help would be great, Thanks
source
share