I am trying to take a CSV file and find the common phrases and the count using Python 2.7. Currently I can only get individual words and their counts, but I need common phrases.
Here's my code so far:
import csv
from sys import argv
from collections import defaultdict
from collections import Counter
script, filename = argv
data = defaultdict(list)
with open (filename, 'rb') as f:
reader = csv.reader(f)
text_file = open("output.txt", "w")
next(reader, None)
for row in reader:
data[row[2]].append(row[3])
text_file.write("%r" % data)
text_file.close()
print(data)
c = Counter(defaultdict)
print c.most_common(10)