Skip to content

Instantly share code, notes, and snippets.

@mdamien
Last active August 29, 2015 14:19
Show Gist options
  • Save mdamien/85402b14bce382d44867 to your computer and use it in GitHub Desktop.
Save mdamien/85402b14bce382d44867 to your computer and use it in GitHub Desktop.
python3 debian parsing
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