Skip to content

Instantly share code, notes, and snippets.

@kuharan
Last active February 15, 2021 18:03
Show Gist options
  • Save kuharan/b48f1e15c09275f70e203962b9c0be07 to your computer and use it in GitHub Desktop.
Save kuharan/b48f1e15c09275f70e203962b9c0be07 to your computer and use it in GitHub Desktop.
JSON to CSV
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