add csv to json python script
This commit is contained in:
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import csv, json, sys
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print("Usage: csv_to_json <input.csv> <output.json>")
|
||||
sys.exit(1)
|
||||
|
||||
with open(sys.argv[1]) as f:
|
||||
data = list(csv.DictReader(f))
|
||||
|
||||
with open(sys.argv[2], 'w') as f:
|
||||
json.dump(data, f, indent=2)
|
||||
Reference in New Issue
Block a user