diff --git a/README.md b/README.md index a265be5..b83ab76 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,13 @@ Usage python /path/to/json_to_csv.py node json_in_file_path csv_out_file_path ``` + +If you want to run the script via a jupyter notebook, you can use code below: + +``` +!python "json_to_csv.py" "STATION" "metadata.json" "metadata__2.csv" +``` + Source Specification -------------------- The script expects the json to be given via a file containing diff --git a/json_to_csv.py b/json_to_csv.py index dbbf2f9..0d74480 100644 --- a/json_to_csv.py +++ b/json_to_csv.py @@ -90,7 +90,7 @@ def reduce_item(key, value): header = list(set(header)) header.sort() - with open(csv_file_path, 'w+') as f: + with open(csv_file_path, 'w+', newline='') as f: writer = csv.DictWriter(f, header, quoting=csv.QUOTE_ALL) writer.writeheader() for row in processed_data: