zemirco / json2csv

Convert json to csv with column titles
http://zemirco.github.io/json2csv
MIT License
2.72k stars 362 forks source link

For Loop in Terminal to Batch Convert JSON to CSV? #533

Closed yawnleashes closed 3 years ago

yawnleashes commented 3 years ago

Hi, I have very little training in terminal or node. Could you help me correct an error in a for loop to batch convert JSON files to CSV in terminal?

I have a folder of 380 JSON files but the terminal command below only converts the first JSON file in the directory 380 times (instead of converting all 380 JSONs).

Could you please help me fix the command to batch all 380 files?

for FILE in *.json; do json2csv -i *.json -f attributes.title,relationships.keywords,relationships.principles -o $FILE.csv; done

yawnleashes commented 3 years ago

never mind figured it out!