Skip to main content

A tool for searching a specific word or phrase in a file.

Project description

Swamauri Logo

PyPI - Downloads GitHub Hits PyPI - Python Version PyPI - License
PyPI - swarmauri_tool_searchword


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

  1. Create an Instance: Instantiate the SearchWordTool class.
  2. Specify Parameters: Provide the file path and the word or phrase you want to search.
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmauri_tool_searchword-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

swarmauri_tool_searchword-0.1.0-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_tool_searchword-0.1.0.tar.gz.

File metadata

File hashes

Hashes for swarmauri_tool_searchword-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e69b8e9d45a40a3450dedb337b85268cd56f5311634049e65100223d98d678b0
MD5 57562848f4fb9742ea515f3461471f43
BLAKE2b-256 6880e0e65adb7d158ed8fcd6a8c76d358c3028f8363459ae4857e9d554030a14

See more details on using hashes here.

File details

Details for the file swarmauri_tool_searchword-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for swarmauri_tool_searchword-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c520e69aa4ed7114ab7a07f64917aa8b2b8e8e3ec9bb51d879a00809516c51cc
MD5 a8227448000458105da6b26829394042
BLAKE2b-256 5d65dd97a612199ad17d46ae1ac94c3199a068d8901bb7d29736f6818390f442

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page