Skip to content

Instantly share code, notes, and snippets.

@lekansogunle
Created December 11, 2019 11:16
Show Gist options
  • Save lekansogunle/65a740e43fd2b01deced1b2d3bc4ab83 to your computer and use it in GitHub Desktop.
Save lekansogunle/65a740e43fd2b01deced1b2d3bc4ab83 to your computer and use it in GitHub Desktop.
import json
import csv
saved_replies = 'saved_replies.json'
with open(saved_replies) as json_data:
d = json.load(json_data)
starting_point = d['saved_replies']
f=csv.writer(open('saved_replies.csv','wb+'))
f.writerow(['Title', 'Summary', 'Details'])
for x in starting_point:
f.writerow([x['name'].encode('utf-8'), x['summary'].encode('utf-8'), "\n".join([(y.get("text") if y.get("text", False) else "\n".join(y.get("items", []))) for y in x["blocks"]]).encode('utf-8')])
print "Complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment