Thanks for the reply Mark, tried that, same result. On Tue, Sep 22, 2015 at 8:58 AM, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
> On 22/09/2015 13:37, richard kappler wrote: > >> 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 >> >> > Your line has EOL on the end. Getting rid of the unneeded brackets try:- > > s = '\x02' + line[:-1] + '\x03\n' > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > _______________________________________________ > Tutor maillist - Tutor@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 - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor