我正在尝试打开一个 csv 文件并将行 append 到列表中。我尝试了一些不同的东西,但我总是得到一个空列表。有什么建议吗?
>>> googleData = []
dataFile = open("googlePrices.csv", 'rU')
for row in dataFile:
googleData.append(row)
>>> googleData
[]
最佳答案
使用 csvreader http://docs.python.org/2/library/csv.html
import csv
csvr = csv.reader(open('googlePrices.csv' , 'r'))
for row in csvr:
....
关于python - 将 csv 文件 append 到 Python 2.7.3 中的一个空列表中 - 返回一个空列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13675556/