[英]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.