Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Textfiles Reader

A collection of Python command-line tools for analyzing and searching text files inside a local directory.

Features

Text Analysis (analyze_text.py)

  • Select a text file from a menu
  • Count lines, words, and non-whitespace characters
  • Generate a word-frequency dictionary
  • Display the top 5 most frequent words

Search and Extract (search_extract.py)

  • Search for a word in a selected file
  • Perform case-insensitive matching
  • Count total occurrences
  • Count matching lines
  • Print matching lines to the terminal
  • Create a new text file containing the matching lines

Project Structure

textfiles-reader/
├── sample-textfiles/
├── analyze_text.py
├── search_extract.py
├── README.md
└── .gitignore

Technologies

  • Python 3
  • Standard library:
    • string
    • time

What I Learned

  • File handling with open()
  • Reading and writing text files
  • Exception handling
  • Dictionaries and frequency counting
  • String processing
  • Removing punctuation with translate()
  • Case-insensitive searching
  • Building command-line interfaces

Sample Output

Text Analysis (analyze_text.py)

Pick a number: 2

→ You selected Clown.txt

This dictionary has 11 key-value pairs.

Total words in this file are 24
Total lines in this file are 1
Total non-whitespace characters in this file are 82

Top 5 most frequent words are:
the — 7 times
car — 3 times
and — 3 times
tent — 2 times
ran — 2 times

Search and Extract (search_extract.py)

Enter file name (with ".txt" extension): clown.txt

What word do you want to look for in clown.txt: the

There is 1 line that contains the word "the".
Total word count: 7

Status

Completed ✔

About

Interactive Python program for reading, parsing, and displaying text files with error handling and user-friendly navigation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages