Last active
February 15, 2021 18:03
-
-
Save kuharan/b48f1e15c09275f70e203962b9c0be07 to your computer and use it in GitHub Desktop.
JSON to CSV
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
def json_to_csv(path, fileInput, fileOutput): | |
inputFile = open(path + fileInput) | |
data = json.load(inputFile) | |
inputFile.close() | |
with open(os.path.join(path,fileOutput), 'w') as fp: | |
output = csv.writer(fp) | |
output.writerow(data[0].keys()) | |
for row in data: | |
output.writerow(row.values()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment