你好,我想读取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]