假设我有一个包含以下列的csv文件:
system component version otherColumn...
type1 abc 4
qwe 5
asd 6
type2 rty 3
type3 vbn 8
asd 9
我想将CSV文件解析为字典,如下所示:
{
type1: { abc: 4, qwe: 5,asd: 6}
type2: { rty: 3}
type3: { vbn: 8, asd: 9}
}
我只想要上面的三列,其他的不需要。你知道吗
我试了以下方法:
import csv
dict = {}
f = open("myfile", 'rt')
reader = csv.reader(f)
for col in row
if col == 'system':
//I am stuck here
有人能帮忙吗?你知道吗
提前谢谢。你知道吗
此处:
相关问题 更多 >
编程相关推荐