2 ms·
Alright, I'm so dang close. With just the issue of write. Here's what I've got so far: in_file = open('c:\original.txt', 'r') out_file = open('c:\output.t
by Random_Person 16y ago
Alright, I'm so dang close. With just the issue of write. Here's what I've got so far:
in_file = open('c:\original.txt', 'r')
out_file = open('c:\output.txt', 'w')
for line in in_file.readlines():
out_file.write('<tr> bgcolor="006699">')
out_file.write(' <td>' + line[0:12] + '<td>')
in_file.close()
out_file.close()
There will be more text written per execution of the loop, but I can handle that coding. :)
What I can't grasp is why write doesn't start a newline and what I can do to remedy that. Currently this is just making a huge line of text instead of individual lines.
Thanks a ton!
- Random_Person 16y agoUgh. Forget I wrote that. :) Amazing what a \n can do! Okay, so, stripping spaces from string values. Easy? If I import my line, I have 6 strings I need to segment out of it and my file uses spaces. So, in my previous line: out_file.write(' <td>' + line[0:12] + '<td>\n') I'd like to strip the spaces from line[0:12] Thanks!
- zephyrfalcon 16y agoline[0:12].strip() but see my other comment about str.split().