[英]How do I write to a CSV with the data ending up in separate columns (currently using arcpy in python 2.7)
我正在使用 arcpy 從 shapefile 中提取信息並將該信息放入 CSV 中。 我想要的是包含信息的 3 個單獨的列,但目前它們合並到一個巨大的列中。
編碼:
f3 = open('ChannelWidth.CSV','a')
cursor2 = arcpy.da.SearchCursor("IntersectPy",['FID','TIME',"SHAPE@LENGTH"])
for row in cursor2:
f3.write(str(row[0]))
f3.write(str(row[1]))
f3.write(str(row[2]))
del cursor2
f3.close()
我想要的是這樣的:
0 1500 0.001334166
1 1500 0.001335145
等等...
所以我的問題是我能做些什么來分離這些值?
for row in cursor2:
f3.write(str(row[0]) + "\t " + str(row[1]) + "\t " + str(row[2]))
應該解決這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.