python - How to write a list of path names on separate rows in csv file? -
i have list of pathnames:
li = [u"c:\\temp\\filea.shp", u"c:\\temp\\fileb.shp", u"c:\\temp\\filec.shp"]
i trying write each path on separate line in txt file. have done far:
import csv li = [u"c:\\temp\\filea.shp", u"c:\\temp\\fileb.shp", u"c:\\temp\\filec.shp"] open(r'c:\temp\myfile.csv', "wb") f: wr = csv.writer(f, delimiter=',', quoting=csv.quote_none) wr.writerows([li])
which yields list of files on same row:
c:\temp\filea.shp,c:\temp\fileb.shp,c:\temp\filec.shp
how can tweak pathnames each on own row? following after:
c:\temp\filea.shp c:\temp\fileb.shp c:\temp\filec.shp
easy need add \n witch means new
import csv li = [u"c:\\temp\\filea.shp", u"c:\\temp\\fileb.shp", u"c:\\temp\\filec.shp"] open(r'c:\temp\myfile.txt', "wb") f: wr = csv.writer(f + '\n', delimiter=',', quoting=csv.quote_none) wr.writerows([li])
so f printed + \n (new line)
Comments
Post a Comment