1) First, install the required libraries.
-pip install Counter
2) Create a file under the name of input in the directory where the python code is located and write the information you want to search there.
Like this:
Code:
Output:
-pip install Counter
2) Create a file under the name of input in the directory where the python code is located and write the information you want to search there.
Like this:
Code:
Python:
from collections import Counter
fileName = "input.txt"
with open(fileName, encoding='utf-8') as doc:
#count = Counter(doc.read().strip().split())
count = Counter(doc.read().strip().split('\n'))
for key, value in count.most_common(1000):
print(key+ " : " + str(value))
Output: