Skip to content

Instantly share code, notes, and snippets.

@maluta
Created December 16, 2013 20:53
Show Gist options
  • Save maluta/7994212 to your computer and use it in GitHub Desktop.
Save maluta/7994212 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
# -*- coding:utf-8 -*-
import re
import csv
import sys
from pytagcloud import create_tag_image, make_tags
from pytagcloud.lang.counter import get_tag_counts
limit = int(sys.argv[-1])
tweets = csv.reader(open("tweets.csv"), delimiter=',', quotechar='"')
buffer = ""
for tweet in tweets:
buffer += tweet[5] + "\n"
buffer = re.sub("(http|www|the|a|we|ours|this|some|who|bit.ly)", "", buffer)
buffer = re.sub("@[a-z]*", "", buffer)
output = "clound_large_%d.png" % limit
tags = make_tags(get_tag_counts(buffer), maxsize=85)
create_tag_image(tags[:limit],
output,
size=(300, 220),
fontname='Old Standard TT')
import webbrowser
webbrowser.open(output) # see results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment