Created
February 2, 2019 22:33
-
-
Save KentaKudo/b1225c971a2f14cef5d4eb2177818cfe to your computer and use it in GitHub Desktop.
An example to parse json into csv format in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json # https://docs.python-guide.org/scenarios/json/ | |
import csv # https://docs.python.org/3/library/csv.html | |
json_string = '[\ | |
{"gender": "Male", "Nationality": "JPN", "document_type": "passport"}\ | |
]' | |
parsed_json = json.loads(json_string) | |
with open('out.csv', 'w', newline='') as csvfile: | |
writer = csv.writer(csvfile) | |
for row in parsed_json: | |
writer.writerow(row.values()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment