im是python的初学者,im试图将csv文件读入python字典以生成html表。
我的文件中有30列,我希望csv文件中的前4列作为列放入html表中,然后在另一个html表中放入6列,依此类推。我的一些列包括字符串,有些列包括整数
csv文件如下:oposition mat won lost total overs
aa 5 3 2 400 20
bb 4 2 2 300 20
cc 4 3 1 100 19
作为im获取数据:
^{pr2}$
到目前为止,我的代码是infile = open("minew.csv", "r")
mydict = {}
for line in infile:
words = line.split(",")
oposition = words[0]
mat = words[1]
won = words[2]
lost = words[3]
mydict[oposition] = oposition
mydict[mat] = int(mat)
mydict[won] = int(won)
mydict[lost] = int(lost)
print("
for o,m,w,l in mydict.keys():
print("
{op} {mt} {wi} {lo}".format(op = mydict[oposition],
mt = mydict[mat]
wi = mydict[won]
lo = mydict[lost]))
print("
")我不能让我的代码生效。请大家帮帮我。
非常感谢