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 withcsvjson
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
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
File details
Details for the file seqpat-0.1.1.tar.gz
.
File metadata
- Download URL: seqpat-0.1.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 676eeb0157f3722543988251e5560d172585cc04d70692322fd2277afc22d574 |
|
MD5 | b9a988c9b9f46816b815b5ad8e062787 |
|
BLAKE2b-256 | f9d366e24c27212be6374531e979f3258d66fce18885bd482298d668df38e8a1 |
File details
Details for the file seqpat-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: seqpat-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f37392919de7fe6b64cdb9c0c8bcf37d57a90e88a15a74a46c2ee5f36dbb4dd0 |
|
MD5 | a796a25ff27a64c2310e6b284bf1feef |
|
BLAKE2b-256 | 06301179c8b82c6d29ceff2f4e66312f9a69225d23967e117da4b7ed2b39f298 |