Skip to content

Instantly share code, notes, and snippets.

@pbindustries
Created October 27, 2018 00:49
Show Gist options
  • Save pbindustries/eff15f34081a7c360365eacb7a846957 to your computer and use it in GitHub Desktop.
Save pbindustries/eff15f34081a7c360365eacb7a846957 to your computer and use it in GitHub Desktop.
import json
import csv
employee_parsed = json.loads(employee_data)
emp_data = employee_parsed['employee_details']
# open a file for writing
employ_data = open('/tmp/EmployData.csv', 'w')
# create the csv writer object
csvwriter = csv.writer(employ_data)
count = 0
for emp in emp_data:
if count == 0:
header = emp.keys()
csvwriter.writerow(header)
count += 1
csvwriter.writerow(emp.values())
employ_data.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment