re: CSV Challenge VIEW POST


I set myself a time limit of 15 minutes, with no google. I did not know how to download using python, so i used wget or powershell. The rest is straight forward.

#!/usr/bin/env python3
import json
from datetime import datetime
import os
from sys import platform

URL = "https://gist.githubusercontent.com/jorinvo/7f19ce95a9a842956358/raw/e319340c2f6691f9cc8d8cc57ed532b5093e3619/data.json"

if platform == "linux" or platform == "linux2" or platform == "darwin":
    os.system("wget -O data.json %s" % URL)
elif platform == "win32" or platform == "win64":
    os.system("powershell Invoke-WebRequest -Uri %s -OutFile data.json" % URL)

with open('data.json', 'r') as input_file:
    input_data = json.load(input_file)

with open('%s.csv' % datetime.today().strftime('%Y%m%d'), 'w') as output_file:
    for victim in input_data:
        if victim['creditcard']:
            output_file.write("%s,%s\n" % (victim['name'], victim['creditcard']))
Code of Conduct Report abuse