Skip to content

Instantly share code, notes, and snippets.

@bennett39
Created April 28, 2023 15:13
Show Gist options
  • Save bennett39/6ea658f31c4201bc82455e36c5ee283e to your computer and use it in GitHub Desktop.
Save bennett39/6ea658f31c4201bc82455e36c5ee283e to your computer and use it in GitHub Desktop.
import csv
with open('cancel.csv') as f:
reader = csv.DictReader(f)
words = {}
for row in reader:
reason = row['Reason']
if reason == 'System cancelled - non payment':
continue
for word in reason.split(' '):
word = word.lower()
if word in ['it', 'to', 'the', 'for', 'this', 'and', 'a', 'my']:
continue
words.setdefault(word, 0)
words[word] += 1
locked = list(words.items())
locked.sort(key=lambda x: x[1], reverse=True)
for word, count in locked[:50]:
print(word, count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment