Coder Social home page Coder Social logo

michagrandel / filtertext Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 126 KB

Simple library and commandline tool to filter text using predefined filters and save the result in a new file

Home Page: https://filtertext.micha.tools

License: Apache License 2.0

Python 100.00%

filtertext's Introduction

Python Apache 2.0 License PyPI - Format PyPI - Status LinkedIn


Logo

Filter Text

Command line tool to filter text and save result to file or print to output!
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About Filter Text
  2. Installation
  3. Usage
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

About The Project

text_filter.py is a simple commandline tool to filter text using predefined filters and save the result in a new file.

You can use it for:

  • Removing lines with whitespaces only in a text file
  • Remove duplicated lines in a text file
  • Extend the functionality by creating your own custom filters

(back to top)

Built With

This is a simple command line tool written in native python 3, no additional dependencies.

Complete list of dependencies:

Python 3.x

(back to top)

Installation

Install via pip:

pip install filtertext

(back to top)

Usage

Command line script

Installation Directory

pip will install a command line script that you can use. To find the installation directory of that script, you can run this code:

python -m site --user-base

Inside of that folder, you will find a folder structure similar to Python312\Scripts or Python312\bin. In this folder, there is a script file filter_text.py.

You can add this folder (../Scripts or ../bin) to your environment variables, so you can run the script without navigating to the folder again.

(back to top)

Run the command line script

You can run the script filter_text.py with some command line arguments:

filter_text.py [-h] [-w] [-d] [-l LIST_FILE] [-D OUTPUT_PATH] [-o OUTPUT_FILE] FILE [FILE ...]

Filter
  -w    Remove lines that only contain whitespace
  -d    Remove duplicate lines

Input
  FILE: files to filter
  -f    LIST_FILE: Input file with list of files to filter, one file per line

Output
  -D    OUTPUT_PATH: Output directory (if it exists, it will be deleted first)
  -o    OUTPUT_FILE: Output file path (if it exists, it will be deleted first)

For more examples, please refer to the Documentation

(back to top)

Python Library

from filtertext import *

file_path = "example.txt"
remove_whitespace = RemoveWhitespaceLinesTextFilter.from_file(file_path)
remove_whitespace.filter()

print(remove_filter.text)

For more examples, please refer to the Documentation

(back to top)

Contributing

Thank you for your interest in contributing! Any contributions you make are greatly appreciated.

Please make sure to follow our Code of Conduct.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue, if you prefer. Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Copyright 2024 Micha Grandel

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

See LICENSE.md for more information.

(back to top)

Contact

Micha Grandel
LinkedIn Email

Project Link: https://github.com/michagrandel/filtertext

(back to top)

Acknowledgments

(back to top)

filtertext's People

Contributors

michagrandel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.