Skip to main content

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.

Metadata

Release files for seqpat 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for seqpat 0.1.1
File Size Uploaded
seqpat-0.1.1.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for seqpat 0.1.1
File Interpreter ABI Platform
seqpat-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 17.4 kB

Release files / seqpat-0.1.1.tar.gz

Download URL seqpat-0.1.1.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
676eeb0157f3722543988251e5560d172585cc04d70692322fd2277afc22d574
BLAKE2b-256 checksum
How to use checksums
f9d366e24c27212be6374531e979f3258d66fce18885bd482298d668df38e8a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release files / seqpat-0.1.1-py3-none-any.whl

Download URL seqpat-0.1.1-py3-none-any.whl
Size 8.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f37392919de7fe6b64cdb9c0c8bcf37d57a90e88a15a74a46c2ee5f36dbb4dd0
BLAKE2b-256 checksum
How to use checksums
06301179c8b82c6d29ceff2f4e66312f9a69225d23967e117da4b7ed2b39f298
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page