No CSV output - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: No CSV output (/thread-3938.html) |
No CSV output - migs2173 - Jul-09-2017 Hi anyone can help me with this coding when i run the script there is a result but doesn't write on csv output file import clearbit import json import sys import csv clearbit.key = 'ske2985fcac3af6dd0334feccae39aa226' if len(sys.argv) < 2: sys.exit('Usage: cli.py domain [role]') domain = sys.argv[1] role = sys.argv[2] people = clearbit.Prospector.search(domain=domain, role=role, email=True) for person in people: print(json.dumps(person, sort_keys=True, indent=4)) s=json.dumps("results") with open("result.csv","w") as resultsFile: resultsFileWriter = csv.writer (resultsFile) resultsFileWriter.writerow(["email", "id", "familyName", "givenName", "role", "seniority", "title", "verified"]) heres the script results { "email": "[email protected]", "id": "e_d5a2004b-e175-49cb-86b4-76c5f41bd51e", "name": { "familyName": "Michael", "fullName": "Emil Michael", "givenName": "Emil" }, "role": "sales", "seniority": "executive", "title": "SVP of Business", "verified": true } { "email": "[email protected]", "id": "e_9c767a05-25d7-4f2f-97b6-f38822f82a83", "name": { "familyName": "Fairchild", "fullName": "Mary Fairchild", "givenName": "Mary" }, "role": "sales", "seniority": "director", "title": "Director of Sales", "verified": true } { "email": "[email protected]", "id": "e_805b4051-7867-4fe2-abc0-fdb8c3f1f77f", "name": { "familyName": "Powers", "fullName": "Matt Powers", "givenName": "Matt" }, "role": "sales", "seniority": "manager", "title": "Business Partner", "verified": true } { "email": "[email protected]", "id": "e_b3f1ea3c-308a-4689-a7ea-963530597b06", "name": { "familyName": "Grant", "fullName": "Allison Grant", "givenName": "Allison" }, "role": "sales", "seniority": "manager", "title": "Senior Business Development Associate", "verified": true } { "email": "[email protected]", "id": "e_ce94bade-efa4-45f7-82e6-94a3aaa19321", "name": { "familyName": "Lee", "fullName": "Hyung Lee", "givenName": "Hyung" }, "role": "sales", "seniority": "manager", "title": "Business Applications Manager", "verified": true } |