Skip to main content

Parser for string sequence, inspired by reguar expressions

Project description

seqpat

seqpat is a Python library designed for flexible and efficient sequence pattern matching, primarily aimed at converting microformats from various command-line tools into JSON Line format.

The motivation behind this project was the idea: "Wouldn't it be great if we could perform operations on a sequence of strings (i.e., lines of text like in a text file) in the same way we use regular expressions on individual strings (i.e., a sequence of characters)?"

Features

  • Pattern Matching: Match sequences of strings using customizable patterns.
  • Sequence Handling: Process and parse structured text data efficiently.
  • Customizable Replacements: Use pattern-based substitutions to transform the input as needed.

Installation

You can install seqpat using pip:

pip install seqpat

Patterns/Utility Functions

The core of seqpat is its ability to define and use flexible patterns for text matching. It provides:

  • R: A pattern that matches regular expressions.
  • gsub: A function for global substitution based on patterns.
  • split_by: A function to split a sequence of strings by a delimiter pattern.

For detailed usage, please refer to the Docstrings, and for examples, see the examples directory.

Related Projects

  • jc: A CLI tool and Python library that converts the output of popular command-line tools (e.g., ls, ps, ifconfig) to JSON or JSON Line for easier parsing and automation.

  • miller: A CLI tool for manipulating CSV and JSON files. For example, you can convert a .csv file to .jsonl format with the following command: $ mlr --icsv --ojsonl cat file.csv

  • csvkit: A CLI tool for converting CSV files to other formats. For instance, you can convert a .csv file to .jsonl format with csvjson command: $ csvjson --stream file.csv

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests on the GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

seqpat-0.1.1.tar.gz (9.4 kB view hashes)

Uploaded Source

Built Distribution

seqpat-0.1.1-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

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