A command line tool that help to find specific words from a file in any selected file.
Project description
“What specific words would you like to read?” Counting words in “Pan Tadeusz” poem
It is a Python-based command-line tool designed to efficiently find and count occurrences of specific words within text files. It offers flexible input options, supporting both individual words, patterns and word lists in various formats.
Python version
tested with Python >= 3.10.6
Why
It was started as a project to exercise python language. The code helped to find specific words in a selected file. It became command line tool that help find any word within any file. The files can be selected by command line
Install
you can run the following command in your terminal to install the program from pip:
pip install PTWordFinder
This will download and install the program, along with any required dependencies.
If you prefer, you can also install the program from source:
Clone the repository containing the program code:
git clone https://github.com/DarekRepos/PanTadeuszWordFinder.git
Replace your-username with your actual username on GitHub. Navigate to the cloned directory:
cd PanTadeuszWordFinder
This method requires poetry or Python build tools. If you don’t have them, install poetry using pip install poetry or install your system’s package manager’s equivalent for build. Install the program using poetry (https://python-poetry.org/):
poetry install
The second method involves directly building the wheel and installing it, which is less commonly used. Install the program directly:
python -m build
python -m pip install dist/PTWordFinder-*.whl
Note:
If you install from source, you will need to have Python development tools installed. You can usually install these using your system’s package manager. Installing from pip is the easiest and most recommended method for most users.
Usage:
python word_counter.py [OPTIONS] Options: -w, --words-input-file FILE File containing words to search for (mutually exclusive with --single-word) -s, --searched-file FILE Path to the text file to search in (required) -w, --single-word WORD Specific word to count (mutually exclusive with --words-input-file) -p, --pattern PATTERN Regular expression pattern to match -h, --help Show this help message and exit
Examples:
Count the word “python” in my_text.txt:
python word_counter.py --single-word python --searched-file my_text.txt
Find the frequency of all words in word_list.txt in large_file.txt:
python word_counter.py --words-input-file word_list.txt --searched-file large_file.txt
Match instances of the regular expression [a-z0-9]{5} in passwords.txt:
python word_counter.py --pattern "[a-z0-9]{5}" --searched-file passwords.txt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ptwordfinder-1.2.9.tar.gz
.
File metadata
- Download URL: ptwordfinder-1.2.9.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5006317fc1640154f6602b39da8b855cae42b84da5c2447067fe3345606a051 |
|
MD5 | 304170fd263746db5a0e389f22a8152f |
|
BLAKE2b-256 | e611be688f9076209dad62d8170d55f6cc295981190280dca1c6a4f94d44cd5f |
File details
Details for the file PTWordFinder-1.2.9-py3-none-any.whl
.
File metadata
- Download URL: PTWordFinder-1.2.9-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fe064e599104a2fadb8e67c2c480d5610a7e7f137a9e95f1c44b6fa965680e1 |
|
MD5 | 56f3b6c35bb0a92d4510ab7e172c6f1a |
|
BLAKE2b-256 | 946b526e384becfd3d87953af61f75953c33ba2258b40c76ee5654307e5fe9f9 |