Skip to content

Instantly share code, notes, and snippets.

@Maurisss94
Created May 16, 2019 11:48
Show Gist options
  • Save Maurisss94/58e50c3fbcbcccd95ac897d4d677e1ff to your computer and use it in GitHub Desktop.
Save Maurisss94/58e50c3fbcbcccd95ac897d4d677e1ff to your computer and use it in GitHub Desktop.
Create a csv, from json files.
import json
import csv
import os, os.path
dir_json = './json'
data = {}
for directory, subdirs, files in os.walk(dir_json):
for filename in files:
filepath = os.path.join(directory, filename)
f = open(filepath, 'r')
data.update(json.load(f))
f.close()
f = csv.writer(open('file.csv', 'w'))
for key, val in data.items():
f.writerow([key +'\t'+ val])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment