json is not converting to csv in python 3.5 -
#!/usr/bin/env python import requests import csv import json import sys s = requests.session() r = s.get('https://onevideo.aol.com/sessions/login?un=username&pw=password') r.status_code if r.status_code == 200: print("logged in successfully") else: print("check username , password") filename = open('outputfile3.csv', 'w') sys.stdout = filename data = s.get('https://onevideo.aol.com/reporting/run_existing_report?report_id=102636').json() json_input = json.load(data) entry in json_input: print(entry) your assignment of sys.stdout = filename not idiomatic, many people may not understand doing. key misunderstanding appear have python interpret either fact have imported csv or extension of file have opened , automatically write valid lines file given list of dictionaries (which .json gets parsed as). i present full example of how write dictionary-like data contrived json reproducability: jsonstr =...