Simple command-line text analysis tool written in Python.
- Print file contents
- Count lines and words
- Find the longest line
- Show the most frequent words in the file
Python 3.x
Run the program with a text file path and optional flags.
Print file contents (default):
python main.py text.txtCount lines and words:
python main.py text.txt --countFind the longest line:
python main.py text.txt --longestShow top N most common words:
python main.py text.txt --top 5$ python main.py text.txt --count
Lines: 3, Words: 9
Execution time: 0.002 seconds
$ python main.py text.txt --top 3
Top words: [('the', 4), ('text', 2), ('example', 2)]
Execution time: 0.002 seconds
main.py– main script for text analysistext.txt– sample input filetext2.txt– additional sample file
This project was built as a learning exercise to practice:
- Python file handling
- command line argument parsing (
argparse) - word frequency analysis (
collections.Counter)
Some guidance was used during development as part of the learning process.
MIT License
Ade - ademirsteventm@gmail.com