# Trivial split for strings with multiple character delimiters, quotes and escaped characters
[![Downloads](https://pepy.tech/badge/tssplit/month)](https://pepy.tech/project/tssplit)
<a href="https://www.buymeacoffee.com/mezantrop" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
## Installation
```shell script
pip install tssplit
```
## Usage
### Syntax
```Python3
def tssplit(s:str, quote:str='"\'', quote_keep:bool=False, delimiter:str=':;,', escape:str='/^',
trim:str='', remark:str='#') -> list[str]:
"""Split a string by delimiters with quotes and escaped characters, optionally trimming results
:param s: A string to split into chunks
:param quote: Quote chars to protect a part of s from parsing
:param quote_keep: Preserve quote characters in the output or not
:param delimiter: A chunk separator character
:param escape: An escape character
:param trim: Trim characters from chunks
:param remark: Ignore all characters after remark sign
:return: A list of chunks
"""
```
### Example
```Python3
import tssplit
tssplit('--:--;--,--"--/--"--\'--:--\'--/"--^--',
quote='"\'', delimiter=':;,', escape='/^', trim='')
['--', '--', '--', '----/------:----"----']
tssplit('--:--;--,--"--/--"--\'--:--\'--/"--^--',
quote='"\'', delimiter=':;,', escape='/^', trim='', quote_keep=True)
['--', '--', '--', '--"--/--"--\'--:--\'--"----']
tssplit('--:--;--,--"--/--"--\'--:--\'--# Ignore this',
quote='"\'', delimiter=':;,', escape='/^', trim='', quote_keep=True, remark='#')
['--', '--', '--', '--"--/--"--\'--:--\'--']
```
## Changelog
* 2020.03.28 v1.0 Initial release
* 2020.03.28 v1.0.1 Many quick fixes to make all things work in PyPI
* 2020.03.29 v1.0.2 Minor fixes, Readme update, Long description provided
* 2020.03.29 v1.0.3 Trim option to strip() characters from chunks
* 2020.03.29 v1.0.4 Multiple characters for quotes, delimiters and escapes
* 2022.02.04 v1.0.5 Added `quote_keep` option to preserve quote marks in the output or not
* 2023.01.12 v1.0.6 Remark characters interrupt string parsing
* 2024.04.03 v1.0.7 Cosmetics to make pylint happy
* 2024.10.19 v1.0.8 Better module import; minor cosmetic changes
* 2024.12.25 v1.0.9 Type annotations by @mkupferman + misc minor changes
Raw data
{
"_id": null,
"home_page": "https://github.com/mezantrop/tssplit",
"name": "tssplit",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "split, parse, quote, trim, strip, string, delimiter, separator",
"author": "Mikhail Zakharov",
"author_email": "zmey20000@yahoo.com",
"download_url": "https://files.pythonhosted.org/packages/8b/ea/ce705a18347a87a7a22dba4f0dd100ba1cc6fca0b3ad4b0613461bfcc90b/tssplit-1.0.9.tar.gz",
"platform": null,
"description": "# Trivial split for strings with multiple character delimiters, quotes and escaped characters\n\n[![Downloads](https://pepy.tech/badge/tssplit/month)](https://pepy.tech/project/tssplit)\n<a href=\"https://www.buymeacoffee.com/mezantrop\" target=\"_blank\"><img src=\"https://cdn.buymeacoffee.com/buttons/default-orange.png\" alt=\"Buy Me A Coffee\" height=\"41\" width=\"174\"></a>\n\n## Installation\n\n```shell script\npip install tssplit\n```\n\n## Usage\n\n### Syntax\n\n```Python3\ndef tssplit(s:str, quote:str='\"\\'', quote_keep:bool=False, delimiter:str=':;,', escape:str='/^',\n trim:str='', remark:str='#') -> list[str]:\n\n \"\"\"Split a string by delimiters with quotes and escaped characters, optionally trimming results\n\n :param s: A string to split into chunks\n :param quote: Quote chars to protect a part of s from parsing\n :param quote_keep: Preserve quote characters in the output or not\n :param delimiter: A chunk separator character\n :param escape: An escape character\n :param trim: Trim characters from chunks\n :param remark: Ignore all characters after remark sign\n :return: A list of chunks\n \"\"\"\n```\n\n### Example\n\n```Python3\nimport tssplit\n\ntssplit('--:--;--,--\"--/--\"--\\'--:--\\'--/\"--^--',\n quote='\"\\'', delimiter=':;,', escape='/^', trim='')\n['--', '--', '--', '----/------:----\"----']\n\ntssplit('--:--;--,--\"--/--\"--\\'--:--\\'--/\"--^--',\n quote='\"\\'', delimiter=':;,', escape='/^', trim='', quote_keep=True)\n['--', '--', '--', '--\"--/--\"--\\'--:--\\'--\"----']\n\ntssplit('--:--;--,--\"--/--\"--\\'--:--\\'--# Ignore this',\n quote='\"\\'', delimiter=':;,', escape='/^', trim='', quote_keep=True, remark='#')\n['--', '--', '--', '--\"--/--\"--\\'--:--\\'--']\n```\n\n## Changelog\n\n* 2020.03.28 v1.0 Initial release\n* 2020.03.28 v1.0.1 Many quick fixes to make all things work in PyPI\n* 2020.03.29 v1.0.2 Minor fixes, Readme update, Long description provided\n* 2020.03.29 v1.0.3 Trim option to strip() characters from chunks\n* 2020.03.29 v1.0.4 Multiple characters for quotes, delimiters and escapes\n* 2022.02.04 v1.0.5 Added `quote_keep` option to preserve quote marks in the output or not\n* 2023.01.12 v1.0.6 Remark characters interrupt string parsing\n* 2024.04.03 v1.0.7 Cosmetics to make pylint happy\n* 2024.10.19 v1.0.8 Better module import; minor cosmetic changes\n* 2024.12.25 v1.0.9 Type annotations by @mkupferman + misc minor changes\n",
"bugtrack_url": null,
"license": "bsd-2-clause",
"summary": "Trivial split for strings with quotes and escaped characters",
"version": "1.0.9",
"project_urls": {
"Homepage": "https://github.com/mezantrop/tssplit"
},
"split_keywords": [
"split",
" parse",
" quote",
" trim",
" strip",
" string",
" delimiter",
" separator"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3dd16b624a6e44a299427615dee45fbb19e2f8d3babeaaac78635d2eca4e7370",
"md5": "7b61ba1211585e930c97873b2e3949da",
"sha256": "4f23f0cb3c7a27c7ed8bb2b3e7ca06606ee268044fc78a20419b9673beb85683"
},
"downloads": -1,
"filename": "tssplit-1.0.9-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7b61ba1211585e930c97873b2e3949da",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4234,
"upload_time": "2024-12-25T17:31:57",
"upload_time_iso_8601": "2024-12-25T17:31:57.572601Z",
"url": "https://files.pythonhosted.org/packages/3d/d1/6b624a6e44a299427615dee45fbb19e2f8d3babeaaac78635d2eca4e7370/tssplit-1.0.9-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8beace705a18347a87a7a22dba4f0dd100ba1cc6fca0b3ad4b0613461bfcc90b",
"md5": "651507f7756f04c66629aba39c2a4bfc",
"sha256": "8e58973e1d69c21fd9b4deeaa757fb6ab8f17b4fa7469387a120f0e99bde8e22"
},
"downloads": -1,
"filename": "tssplit-1.0.9.tar.gz",
"has_sig": false,
"md5_digest": "651507f7756f04c66629aba39c2a4bfc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3570,
"upload_time": "2024-12-25T17:31:59",
"upload_time_iso_8601": "2024-12-25T17:31:59.596948Z",
"url": "https://files.pythonhosted.org/packages/8b/ea/ce705a18347a87a7a22dba4f0dd100ba1cc6fca0b3ad4b0613461bfcc90b/tssplit-1.0.9.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-25 17:31:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mezantrop",
"github_project": "tssplit",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tssplit"
}