A tool for searching a specific word or phrase in a file.
Project description
swarmauri_tool_searchword
A tool for extracting the number of occurances of a word or phrase (case insensitive) within a file.
Installation
To install the swarmauri_tool_searchword package, you can use pip. Ensure that you have Python 3.10 or newer installed on your system. You can install the package directly from PyPI using the following command:
pip install swarmauri_tool_searchword
If you are using Poetry for dependency management, you can add it to your project by executing:
poetry add swarmauri_tool_searchword
Usage
The swarmauri_tool_searchword package provides a single class, SearchWordTool, to search for specific words or phrases within a file. Below is an example of how to use it.
Example
from swarmauri_tool_searchword import SearchWordTool
# Create an instance of the SearchWordTool
search_tool = SearchWordTool()
# Specify the file path and the search word
file_path = 'path/to/your/file.txt'
search_word = 'your_search_term'
# Execute the search
result = search_tool(file_path=file_path, search_word=search_word)
print(f"Occurrences of '{search_word}': {result['count']}")
for line in result['lines']:
print(line)
Functionality
- Create an Instance: Instantiate the
SearchWordToolclass. - Specify Parameters: Provide the file path and the word or phrase you want to search.
- Execute the Search: Call the instance with the specified parameters to get the occurrences.
This package highlights the occurrences of the search term in the output, making it easy to identify where the term appears in the text.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_tool_searchword-0.1.0.dev18.tar.gz.
File metadata
- Download URL: swarmauri_tool_searchword-0.1.0.dev18.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
313974409e2277dbc49376c9a06b2faab5bfa06eff191034cbaec7786690fe34
|
|
| MD5 |
670589e8d43068e7b35b08e903d496c7
|
|
| BLAKE2b-256 |
19771ba62a61f32cbc027ba2c7901762da38af0eb4d3658e2b4bdfbce3666b46
|
File details
Details for the file swarmauri_tool_searchword-0.1.0.dev18-py3-none-any.whl.
File metadata
- Download URL: swarmauri_tool_searchword-0.1.0.dev18-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cf21eedb25e0d07c27451cc601506ad3c0d79e2ed934b3a3a83af16f9115f68
|
|
| MD5 |
b3d2bae277ec86eb1b978b74e88e1d06
|
|
| BLAKE2b-256 |
7d69a3a22f232d303c74d5007901ad81abf9dd1662d60c15d6488259d7cdead1
|