Skip to content

Instantly share code, notes, and snippets.

@maximveksler
Created September 3, 2014 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximveksler/410917425c7c4bbf8cc7 to your computer and use it in GitHub Desktop.
Save maximveksler/410917425c7c4bbf8cc7 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import csv
import re
from collections import Counter, OrderedDict
count_total = Counter()
count_by_date = {}
def get_count_today(by_date):
if not by_date in count_by_date:
count_by_date[by_date] = Counter()
return count_by_date[by_date]
with open('dribbble.csv', 'rb') as csvfile:
spamreader = csv.reader(csvfile, delimiter=',')
for row in spamreader:
delimiters = "; "
regexPattern = '|'.join(map(re.escape, delimiters))
tags_string=row[11]
by_date = row[8]
# Count the tags
tags = re.split(regexPattern, tags_string)
for t in tags:
if t:
count_total[t] += 1
get_count_today(by_date)[t] += 1
print "Total\n\n", count_total.most_common(50), "\n\n"
print "By Date:"
for by_date_counter in OrderedDict(sorted(count_by_date.items(), key=lambda t: t[0])):
print by_date_counter, ": \n", count_by_date[by_date_counter].most_common(50)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment