[Tutor] how to join two text files ?
Blockheads Oi Oi
breamoreboy at yahoo.co.uk
Sun Mar 27 15:44:08 CEST 2011
On 26/03/2011 21:08, 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
> 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?)?
> Best regards,
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
Maybe use split like this,
'x y 123.456\n'.split()
['x', 'y', '123.456']
then store the x and y coords in a dict with a list of values, perhaps
sort according to your needs, write output to file.
More information about the Tutor