DEV Community

Discussion on: CSV Challenge

Collapse
 
alexdante profile image
alex䷰dante • Edited
import csv
import requests

LEAK_URL = 'https://gist.githubusercontent.com/jorinvo/7f19ce95a9a842956358/raw/e319340c2f6691f9cc8d8cc57ed532b5093e3619/data.json'

with open('20171112.csv', 'w') as csv_file:
    writer = csv.DictWriter(csv_file, ['Name', 'Credit Card'])
    writer.writeheader()
    writer.writerows(
        {'Name':x['name'],'Credit Card':x['creditcard']} for x in requests.get(LEAK_URL).json() if x['creditcard']
    )