csv2json

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)