[Tutor] how to join two text files ?
Rafael Durán Castañeda
rafadurancastaneda at gmail.com
Tue Mar 29 11:09:42 CEST 2011
If you need read files like Example file_1 and file_2 you could use csv
reader, look this code and think how you could use it:
f1 = csv.reader(open('file1', newline=''),delimiter=' ')
for a, b, c in f1:
print('%s %s %s' % (a, b, c))
2011/3/29 Peter Otten <__peter__ at web.de>
> Mateusz K wrote:
> > I have many text files, where data is delimited by space.
> > Each file contain three colums: coordinate x, coordinate y and value for
> > this location.
> > I would like to join this data to get one big file which will
> > contain columns:
> > coordinate x, coordinate y, value1,value2,..., value_n and save it to
> > another text file.
> > I wrote script, but there's some stupid error (like "\n" character
> > although I have added .rstrip() command).
> > Coul You tell me what is most convenient way to join this data
> > (maybe by using csv module?)?
> Please show us the code that you have. This proves that you've put some
> effort into the matter and allows us to focus on the missing parts.
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor