Dump after processing whole rows.
import csv
import json
with open('test.csv') as f:
reader = csv.DictReader(f)
rows = list(reader)
with open('test.json', 'w') as f:
json.dump(rows, f)
More Related Contents:
- How can I convert JSON to CSV?
- How to convert CSV file to multiline JSON?
- Convert nested JSON to CSV file in Python
- Update a CSV file?
- How to return a dict as a JSON response from a Flask view?
- Saving utf-8 texts with json.dumps as UTF8, not as \u escape sequence
- How do I read and write CSV files with Python?
- How to get rid of “Unnamed: 0” column in a pandas DataFrame read in from CSV file?
- Python convert csv to xlsx
- How do I automatically fix an invalid JSON string?
- Django JSONField inside ArrayField
- CSVWriter not saving data to file the moment I write it
- Python CSV to SQLite
- Deserialize a json string to an object in python
- TypeError: the JSON object must be str, not ‘bytes’
- JSON serialize a dictionary with tuples as key
- Python DictWriter writing UTF-8 encoded CSV files
- Convert tab-delimited txt file into a csv file using Python
- Numpy loading csv TOO slow compared to Matlab
- How convert a jpeg image into json file in Google machine learning
- Pyspark: Parse a column of json strings
- How to read one single line of csv data in Python?
- How can I extract a single value from a nested data structure (such as from parsing JSON)?
- Python: skip comment lines marked with # in csv.DictReader
- TypeError: Object of type ‘bytes’ is not JSON serializable
- Python Flask, TypeError: ‘dict’ object is not callable
- Python 3 CSV file giving UnicodeDecodeError: ‘utf-8’ codec can’t decode byte error when I print
- Python and JSON – TypeError list indices must be integers not str
- Plot NetworkX Graph from Adjacency Matrix in CSV file
- How can I diagnose common errors in JSON data?