Skip to content

Instantly share code, notes, and snippets.

@nbortolotti
Created August 31, 2015 01:30
Show Gist options
  • Select an option

  • Save nbortolotti/5fcd0ef557b92b8c08cb to your computer and use it in GitHub Desktop.

Select an option

Save nbortolotti/5fcd0ef557b92b8c08cb to your computer and use it in GitHub Desktop.
try:
writer = csv.writer(myfile)
writer.writerow(('id', 'content', 'test', 'replies', 'plusoners', 'resharers'))
# Information from activities
count = 0
while (count < postnumers):
activities_document = request.execute()
if 'items' in activities_document:
for activity in activities_document['items']:
id =activity['id']
content = activity['object']['content'].encode("utf-8")
test = any(x in content.split() for x in tech)
replies =activity['object']['replies']['totalItems']
plusoners =activity['object']['plusoners']['totalItems']
resharers = activity['object']['resharers']['totalItems']
writer.writerow((id, content, test ,replies, plusoners, resharers))
count = count + 1
request = service.activities().list_next(request, activities_document)
finally:
myfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment