Created
March 8, 2010 16:44
-
-
Save sandaru1/325337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urlparse import urlparse | |
import csv | |
f = csv.reader(open('fixed.csv')) | |
domains = {} | |
counts = {} | |
used = {} | |
for row in f: | |
if (row[9] not in used): | |
used[row[9]] = 0 | |
domain = urlparse(row[1])[1] | |
if (domain == ""): | |
domain = "ASK" | |
if (domain not in counts): | |
counts[domain] = 1 | |
else: | |
if (used[row[9]] == 0): | |
counts[domain] += 1 | |
if (domain not in domains): | |
domains[domain] = int(row[3]) | |
else: | |
domains[domain] += int(row[3]) - used[row[9]] | |
used[row[9]] = int(row[3]) | |
for d in domains.keys(): | |
if (counts[d]<10): continue | |
print d,str(round(domains[d]/float(counts[d]),2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urlparse import urlparse | |
import csv | |
f = csv.reader(open('fixed.csv')) | |
domains = {} | |
used = {} | |
for row in f: | |
if (row[9] not in used): | |
used[row[9]] = 0 | |
domain = urlparse(row[1])[1] | |
if (domain == ""): | |
domain = "ASK" | |
if (domain not in domains): | |
domains[domain] = int(row[3]) | |
else: | |
domains[domain] += int(row[3]) - used[row[9]] | |
used[row[9]] = int(row[3]) | |
for d in domains.keys(): | |
print d,domains[d] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from urlparse import urlparse | |
import csv | |
f = csv.reader(open('fixed.csv')) | |
domains = {} | |
used = {} | |
for row in f: | |
if (row[9] in used): | |
continue | |
used[row[9]] = True | |
domain = urlparse(row[1])[1] | |
if (domain == ""): | |
domain = "ASK" | |
if (domain not in domains): | |
domains[domain] = 1 | |
else: | |
domains[domain] += 1 | |
for d in domains.keys(): | |
print d,domains[d] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment