pip install doitlive
python
import argparse
from collections import Counter
def count_words(file_path):
with open(file_path, 'r') as file:
words = file.read().split()
word_count = Counter(words)
return word_count
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Word Counter')
parser.add_argument('file', help='Input file path')
args = parser.parse_args()
word_count = count_words(args.file)
for word, count in word_count.items():
print(f'{word}: {count}')
config color: true
config output_file: word_counter_output.txt
session:
- doitlive:
live: python word_counter.py sample.txt
echo: "Counted words in sample.txt file"
doitlive play word_counter.txt