Skip to main content

Getting started

python-textops3 provides many text operations at string level, list level or whole text level.
These operations can be chained with a ‘dotted’ or ‘piped’ notation.
Chained operations are stored into a single lazy object, they will be executed only when an input text will be provided.

Install

To install:

pip install python-textops3

Overview

The usual way to use textops is something like below. IMPORTANT : Note that textops library redefines the python bitwise OR operator ‘|’ in order to use it as a ‘pipe’ like in a Unix shell:

from textops import *

result = "an input text" | my().chained().operations()

or

for result_item in "an input text" | my().chained().operations():
   do_something(result_item)

or

myops = my().chained().operations()
# and later in the code, use them :
result = myops("an input text")
or
result = "an input text" | myops

An “input text” can be :

  • a simple string,

  • a multi-line string (one string having newlines),

  • a list of strings,

  • a strings generator,

  • a list of lists (useful when you cut lines into columns),

  • a list of dicts (useful when you parse a line).

So one can do:

>>> 'line1line2line3' | grep('2').tolist()
['line1line2line3']
>>> 'line1\nline2\nline3' | grep('2').tolist()
['line2']
>>> ['line1','line2','line3'] | grep('2').tolist()
['line2']
>>> [['line','1'],['line','2'],['line','3']] | grep('2').tolist()
[['line', '2']]
>>> [{'line':1},{'line':'2'},{'line':3}] | grep('2').tolist()
[{'line': '2'}]

Examples

Piped then dotted notation (recommended):

>>> print('this is an error\nthis is a warning' | grepi('error').first().upper())
THIS IS AN ERROR

You could use the pipe everywhere (internally a little less optimized, but looks like shell):

>>> print('this is an error\nthis is a warning' | grepi('error') | first() | strop.upper())
THIS IS AN ERROR

To execute an operation directly from strings, lists or dicts with the dotted notation, you must use textops Extended types : StrExt, ListExt or DictExt:

>>> s = StrExt('this is an error\nthis is a warning')
>>> print(s.grepi('error').first().upper())
THIS IS AN ERROR

Documentation

Please, read documentation here :

News

3.2.1 (2022-03-31)

  • add Python 3.10 support

3.1.0 (2020-06-25)

  • add TupleExt

  • DictExt now support pickle

3.0.8 (2019-10-08)

  • add encoding & encoding_errors arguments to cat()

3.0.7 (2019-10-01)

  • add separators argument to parse_smart()

3.0.6 (2019-09-25)

  • add key_filter argument to parse_smart()

3.0.5 (2019-06-14)

  • add decode_bytes()

3.0.3 (2018-11-07)

  • Migrate from python 2 to python 3

Metadata

Release files for python-textops3 3.2.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 python-textops3 3.2.1
File Size Uploaded Provenance Actions
python-textops3-3.2.1.tar.gz 89.9 kB Without provenance Details for python-textops3-3.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-textops3 3.2.1
File Interpreter ABI Platform Actions
python_textops3-3.2.1-py3-none-any.whl Python 3 none any Details for python_textops3-3.2.1-py3-none-any.whl

Total release size: 152.1 kB

Release files / python-textops3-3.2.1.tar.gz

Download URL python-textops3-3.2.1.tar.gz
Size 89.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b99768eda465a333bfd61ac75fafc71044f1d4d8fc67568d8e0163316805f39d
BLAKE2b-256 checksum
How to use checksums
6dba116d6220c6e844bb64c9af9f97dabdff1a07b23449b4ae651e78e7a984dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

Release files / python_textops3-3.2.1-py3-none-any.whl

Download URL python_textops3-3.2.1-py3-none-any.whl
Size 62.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da9c5358d132e4d90b52792d0e9bcee81f5f03f5320b4456f2429588f1cd7903
BLAKE2b-256 checksum
How to use checksums
1c5a0f03be7363710c519b1874cfd525e66a05d24da7c710c9634d6d5568efa5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.4

Security for python-textops3 3.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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