Skip to content

Instantly share code, notes, and snippets.

@7h3rAm
Created November 30, 2015 04:59
Show Gist options
  • Save 7h3rAm/e3e445f677387310544a to your computer and use it in GitHub Desktop.
Save 7h3rAm/e3e445f677387310544a to your computer and use it in GitHub Desktop.
from utils import read_json
cc_data = read_json('cc.json')
outfile = open('cc.csv', 'w')
for people in cc_data:
print people
if 'creditcard' in people and people['creditcard']:
line_str = '{name},{email}\n'.format(
name=people['name'],
email=people['email'])
outfile.write(line_str)
print '----- OK -----'
outfile.close()
import requests
import time
url = 'https://gist.githubusercontent.com/jorin-vogel/7f19ce95a9a842956358/raw/e319340c2f6691f9cc8d8cc57ed532b5093e3619/data.json'
data = requests.get(url).json()
with open(time.strftime("%Y%m%d.csv"), 'w') as outfile:
outfile.write('name,creditcard\n')
outfile.writelines(['{name},{creditcard}\n'.format(**l) for l in data if l['creditcard']])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment