Created
May 16, 2019 11:48
-
-
Save Maurisss94/58e50c3fbcbcccd95ac897d4d677e1ff to your computer and use it in GitHub Desktop.
Create a csv, from json files.
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 | |
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