A fun beginner Python project for practicing file handling! ๐
This project helps you read and analyze any text file (sample.txt) using Python.
Itโs designed for beginners to understand how to:
- Open files using
open()andwith open() - Read text from a file
- Count lines, words, and characters
- Search for words inside text
- Save results into a simple report file
Itโs small, simple, and perfect for learning the basics of Python file handling.
โ
How to open, read, and close files in Python
โ
How to use read(), readline(), and loops
โ
How to search text and count words
โ
How to write data into another file
โ
How to build and organize a beginner project
text-analyzer/ โโโ README.md โโโ main.py โโโ sample.txt
Step 2: Run the program
Make sure you have Python installed (3.8 or higher). Then run:
python main.py
๐งฉ Features Feature Description ๐ Read Text File Opens and displays your text file ๐งฎ Count Stats Shows total lines, words, and characters ๐ Word Search Finds lines containing your keyword ๐ Save Report Creates a simple report file with text stats ๐ง Beginner Friendly Perfect for learning Python basics ๐ Example Output ๐ Text Reader & Analyzer
1๏ธโฃ Show full text 2๏ธโฃ Count lines, words, characters 3๏ธโฃ Search for a word 4๏ธโฃ Save a report 0๏ธโฃ Exit
Enter your choice: 2 ๐ Text Summary: Lines: 5 Words: 47 Characters: 290
๐ง Sample Text (sample.txt)
You can start with this simple text file:
Python is fun to learn. Reading and writing files makes it even better! This is a beginner project to understand file handling. Let's keep learning and growing with Python!
๐พ Output Report (report.txt)
When you choose option 4, your report will look like this:
File: sample.txt Lines: 5 Words: 47 Characters: 290
๐ก Ideas to Improve
Here are a few fun ideas to make this project even better:
Add colors to the output using colorama ๐ Show the top 3 most common words Allow the user to choose a custom file name Add reading time estimation (based on word count) Display a progress bar while reading the file
๐งโ๐ป Technologies Used: Python 3.x No external libraries โ just built-in functions!
๐ฉโ๐ซ Author Varrun Vashisht