Skip to content

Instantly share code, notes, and snippets.

@edsu edsu/jobs.py
Last active Apr 25, 2019

Embed
What would you like to do?
#!/usr/bin/env python3
import re
import csv
import json
import twarc
import string
import collections
jobs = collections.Counter()
twitter = twarc.Twarc()
for tweet in twitter.search('5jobsivehad'):
if 'retweeted_status' in tweet:
continue
text = tweet['full_text']
for line in text.split('\n'):
m = re.match(r'^[1-5][' + string.punctuation + ']? (.+)', line)
if m:
job = m.group(1).lower()
if not re.search("jobs i.ve had", job):
jobs[job] += 1
output = csv.writer(open('jobs.csv', 'w'))
output.writerow(['job', 'count'])
for job, count in jobs.most_common():
output.writerow([job, count])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.