CSV清单清单

时间:2018-06-20 16:15:49

标签: python python-3.x

你好,我想读取csv文件,然后将所有行保存在单独的列表中

root = Tk()
f = askopenfilenames(parent=root)
for file in f:
with open(file) as csvfile:
   dialect = csv.Sniffer().sniff(csvfile.readline())
   csvfile.seek(0)
   dictlist = list(csv.reader(csvfile,dialect=dialect))

dictlist看起来像这样:

dictlist = [
[1, John, Washington]
[2, Marie, California]
[3, Brad, Texas]
]

现在我想将每一行保存在这样的列表中:

row0 = [ 1, 2, 3]
row1 = [John, Marie, Brad]
row2 = [Washington, California, Texas]

0 个答案:

没有答案