richard kappler
2015-09-22 12:37:56 UTC
I have a file with several lines. I need to prepend each line with \x02 and
append each line with \x03 for reading into Splunk. I can get the \x02 at
the beginning of each line, no problem, but can't get the \x03 to go on the
end of the line. Instead it goes to the beginning of the next line.
I have tried:
#!/usr/bin/env python
with open('input/test.xml', 'r') as f1:
with open('mod1.xml', 'a') as f2:
for line in f1:
s = ('\x02' + line + '\x03')
f2.write(s)
as well as the same script but using .join, to no avail. What am I missing?
regards, Richard
append each line with \x03 for reading into Splunk. I can get the \x02 at
the beginning of each line, no problem, but can't get the \x03 to go on the
end of the line. Instead it goes to the beginning of the next line.
I have tried:
#!/usr/bin/env python
with open('input/test.xml', 'r') as f1:
with open('mod1.xml', 'a') as f2:
for line in f1:
s = ('\x02' + line + '\x03')
f2.write(s)
as well as the same script but using .join, to no avail. What am I missing?
regards, Richard
--
All internal models of the world are approximate. ~ Sebastian Thrun
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
All internal models of the world are approximate. ~ Sebastian Thrun
_______________________________________________
Tutor maillist - ***@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor