csv2json

作者: 饿了爸 | 来源:发表于2017-05-09 17:53 被阅读0次

import csv

import json

csvfile = open('file.csv', 'r')

jsonfile = open('file.json', 'w')

fieldnames = ("FirstName","LastName","IDNumber","Message")

reader = csv.DictReader( csvfile, fieldnames)

for row in reader:

json.dump(row, jsonfile)

jsonfile.write('\n')

相关文章

  • csv2json

    import csv import jsoncsvfile = open('file.csv', 'r')json...

网友评论

      本文标题:csv2json

      本文链接:https://www.haomeiwen.com/subject/wgditxtx.html