Last active
August 29, 2015 14:19
-
-
Save mdamien/85402b14bce382d44867 to your computer and use it in GitHub Desktop.
python3 debian parsing
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 os,json,csv | |
from os.path import join, getsize | |
header = True | |
with open('status.csv', 'w', newline='') as csvfile: | |
c = csv.writer(csvfile) | |
for root, dirs, files in os.walk('pool'): | |
for filename in files: | |
with open(join(root,filename)) as fp: | |
r = json.load(fp) | |
keys = sorted(r.keys()) | |
if header: | |
c.writerow(['filename']+keys) | |
header = False | |
c.writerow([filename]+[key if r[key] else '' for key in keys]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment