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?
答案 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]