python CSVをJSONに変换するごく简単なPython中のスクリプト。简単だけど変换の作业がある度に调べる気がするのでメモ。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python CSVをJSONに変换するごく简単なPython中のスクリプト。简単だけど変换の作业がある度に调べる気がするのでメモ。相关的知识,希望对你有一定的参考价值。

import csv
import json
csvfile = open('sourcefile.csv', 'r')
jsonfile = open('result.json', 'w')
fieldnames = ("x","y","judge","flag")
reader = csv.DictReader(csvfile, fieldnames)
for row in reader:
  json.dump(row, jsonfile)
  jsonfile.write(',\n')

以上是关于python CSVをJSONに変换するごく简単なPython中のスクリプト。简単だけど変换の作业がある度に调べる気がするのでメモ。的主要内容,如果未能解决你的问题,请参考以下文章