Skip to main content

simplifies the process of splitting a list of strings at specified character indices

Project description

simplifies the process of splitting a list of strings at specified character indices

Tested against Windows 10 / Python 3.10 / Anaconda

pip install stringindexsplit

Description:

The SplitStringsAtIndices package is a Python utility that simplifies the process of splitting a list of strings at specified character indices. Whether you're working with text data in data analysis, natural language processing, or text processing tasks, this package provides a handy tool to efficiently split strings and extract substrings based on your requirements.

Key Features:

Flexible Input:

Accepts a variety of input formats, including lists, tuples, and NumPy arrays, making it compatible with different data structures.

Precise Splitting:

Specify the exact character indices at which you want to split your strings, giving you full control over the extraction process.

Efficient Processing:

Utilizes NumPy for efficient array manipulation, ensuring fast and optimized splitting of strings.

2D NumPy Output:

Returns a 2D NumPy array where each row contains the split strings, facilitating further analysis and manipulation. Why Choose SplitStringsAtIndices?

split_list_of_strings_at_indices(
    strings: Union[list, tuple, np.ndarray], splitlist: Union[list, tuple, np.ndarray]
) -> np.ndarray:
r"""
Splits a list of strings at specified character indices.

:param strings: List of strings to be split.
:type strings: Union[list, tuple, np.ndarray]

:param splitlist: List of indices at which to split the strings.
:type splitlist: Union[list, tuple, np.ndarray]

:return: 2D NumPy array where each row contains the split strings.
:rtype: np.ndarray

Example usage:
>>> from stringindexsplit import split_list_of_strings_at_indices
>>> stringlist = '''For most Unix systems, you must download and compile the source code. The same source code archive can also be used to build the Windows and Mac versions, and is the starting point for ports to all other platforms.'''.split()
>>> splist = split_list_of_strings_at_indices(
...     stringlist,
...     splitlist=(
...         0,
...         2,
...         3,
...         6,
...         7,
...     ),
... )
>>> print(splist)

[['Fo' 'r' '' '' '']
 ['mo' 's' 't' '' '']
 ['Un' 'i' 'x' '' '']
 ['sy' 's' 'tem' 's' ',']
 ['yo' 'u' '' '' '']
 ['mu' 's' 't' '' '']
 ['do' 'w' 'nlo' 'a' 'd']
 ['an' 'd' '' '' '']
 ['co' 'm' 'pil' 'e' '']]

Project details


Release history Release notifications | RSS feed

This version

0.10

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stringindexsplit-0.10.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

stringindexsplit-0.10-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file stringindexsplit-0.10.tar.gz.

File metadata

  • Download URL: stringindexsplit-0.10.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for stringindexsplit-0.10.tar.gz
Algorithm Hash digest
SHA256 49c2b2a7461ae5793798b6b099d9a55461f2dceca937673e1fef5767b7509378
MD5 655d07f6d6d69de2a2592fc4727f0ae1
BLAKE2b-256 047fe84532f2d1ddbec2dbf1d17e5f3adcfaec2aaa8b18994aa7ee45b8989580

See more details on using hashes here.

File details

Details for the file stringindexsplit-0.10-py3-none-any.whl.

File metadata

File hashes

Hashes for stringindexsplit-0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 fedd014234386a05676c19c99823f5db99c3c6d6d2ee9c74ed165bec34031b38
MD5 d861ac2f61b344e1f8c70f0a4599b74b
BLAKE2b-256 8d7010c773418e9a4e24d19de39da4a52292e315e3c0b5e829015e5a1a4cfee1

See more details on using hashes here.

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