[Tutor] write list to columns

questions anon questions.anon at gmail.com
Thu Apr 12 04:31:13 CEST 2012


I am trying to simply write a list of values to txt file in one column.
I would then like to add another list in a second column.
Somehow they only appear as one long row.
Any feedback will be greatly appreciated.

print "rain max values", rmax
print "yearmonth", monthyear

OutputFolder=r"E:/test_out/"
myfile=open(OutputFolder+'test.txt','w')
myfile.write(str(monthyear))
myfile.write(str(rmax))
myfile.close()

In python:
rain max values [43.8748, 35.838270000000001, 18.659849999999999,
60.201709999999999, 21.69989, 25.27929, 16.081009999999999,
14.198729999999999, 33.5246, 19.710170000000002, 22.904209999999999,
17.301929999999999, 39.372410000000002, 39.290640000000003,
25.442820000000001, 33.322339999999997, 28.252970000000001,
40.388719999999999, 8.7627600000000001, 54.516460000000002, 109.756,
15.863519999999999, 31.598600000000001]
yearmonth ['20110906', '20110907', '20110908', '20110909', '20110910',
'20110911', '20110912', '20110913', '20110914', '20110915', '20110916',
'20110917', '20110918', '20110919', '20110920', '20110921', '20110922',
'20110923', '20110924', '20110925', '20110926', '20110927', '20110928']

in my text file:
['20110906', '20110907', '20110908', '20110909', '20110910', '20110911',
'20110912', '20110913', '20110914', '20110915', '20110916', '20110917',
'20110918', '20110919', '20110920', '20110921', '20110922', '20110923',
'20110924', '20110925', '20110926', '20110927', '20110928'][43.8748,
35.838270000000001, 18.659849999999999, 60.201709999999999, 21.69989,
25.27929, 16.081009999999999, 14.198729999999999, 33.5246,
19.710170000000002, 22.904209999999999, 17.301929999999999,
39.372410000000002, 39.290640000000003, 25.442820000000001,
33.322339999999997, 28.252970000000001, 40.388719999999999,
8.7627600000000001, 54.516460000000002, 109.756, 15.863519999999999,
31.598600000000001]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120412/9e190a73/attachment-0001.html>


More information about the Tutor mailing list