How can I access individual cells in a csv document to parse and edit them? Also is there a way I can convert the csv document into a two-dimensional array?
问问题
3564 次
2 回答
1
这是为您提供的解决方案。
import csv
twoDimArray = []
with open('input.csv', 'rb') as csvfile:
reader = csv.reader(csvfile, delimiter=';', quotechar='|')
for row in reader:
twoDomArray.append(row)
#DO STUFF WITH DATA
with open('output.csv', 'wb') as csvfile:
writer = csv.writer(csvfile, delimiter=' ',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
for row in twoDinArray:
writer.writerow(row)
另请阅读文档
祝你好运:)
于 2012-12-05T03:10:58.803 回答