标签: python csv dictionary
我需要将csv文件的每一行作为一个列表,而该列表又是特定字典键的值。 下一行将是列表,该列表充当同一字典的某个其他键的值。 这是代码:
tehsils_in_district=defaultdict i = 1 with open("district_list.csv",'rb') as f: for row in csv.reader(f): tehsils_in_district[i] = row i = i+1