JSON to CSV with python

时间:2018-09-19 08:28:00

标签: python json pandas csv

I am doing a data analysis project and I need to convert the files from JSON to CSV.

I started learning python just recently. Here is my code for json to csv(json2csv.py).

It works with specified file defined in json2csv.py.

I want to modify it with run json2csv.py "RFC.json" in the terminal.

How can I modify this?

code

1 个答案:

答案 0 :(得分:0)

import sys

with open(sys.argv[1], 'r') as f:
    json_raw_data = json.load(f)

现在键入

  

python json2csv.py“ RFC.json”

它将RFC.json分配给sys.argv [1]