Skip to main content

textfield_parser

Getting a string from a textfield and returns the parsed content.

read_list

Reads a comma separated list and returns either the items or the remainder of the additional list when a text contains the modifier 'Not'.

def read_list(text,value_list=None,sep = ',', modifier_list = None)`

Arguments

  • text -string- from textfield that will be parsed
  • value_list -list- list from which the parsed text elements will be removed when there is a modifier 'NOT'.
  • sep -char- element separator in string
  • modifier_list -list- List of modifier for excluding the listed items from value_list Default: ['!', '~', 'not', 'Not', 'NOT']

Return

  • List of parsed parameters

Examples

**Simple list: **

  • text = "'Hello', 'a list', separated by , me "

-> ['Hello', 'a list', 'separated by', 'me']

Not list

  • text = "Not Mercedes, Renault, Citroen, Peugeaut, 'Rolls Royce'"
  • value_list = ['Mercedes', 'Audi', 'VW', 'Skoda', 'Renault', 'Citroen', 'Peugeot', 'Rolls Royce']

-> ['Audi', 'VW', 'Skoda', 'Peugeot']

read_map

Reads a comma separated list of mappings and returns a dictionary.

def read_map(text, sep=',')

Arguments

  • text -string- from textfield that will be parsed
  • sep -char- element separator in string

Return

  • dictionary of parsed parameters

Example

text = "'Mercedes':expensive, Audi:'sportiv', VW : 'people', Citroen:cool, 'Rolls Rocye': royal"

-> {'Mercedes': 'expensive', 'Audi': 'sportiv', 'VW': 'people', 'Citroen': 'cool', 'Rolls Rocye': 'royal'}

read_json

Reads a json formatted string and return a dictionary

Arguments

  • text -string- json-string

Return

  • dictionary of json

Example

json_text = "{"Luxury Class": {"Mercedes":"expensive","Rolls Rocye": "royal"}, "High Middle Class":{"Audi":"sportiv"}, "Middle Class" : {"Citroen":"cool","VW" : "people" }}"

-> {'Luxury Class': {'Mercedes': 'expensive', 'Rolls Rocye': 'royal'}, 'High Middle Class': {'Audi': 'sportiv'}, 'Middle Class': {'Citroen': 'cool', 'VW': 'people'}}

read_comparisons

Parses a list of comparisons and returns a list of lists with 3 items: (left, comparison-operator, right). There is an internal mapping of comparison characters: {'!=':'!','==':'=','>=':'≥','=>':'≥','<=':'≤','=<':'≤'}

def read_comparisons(text,sep = ',',formula_map = None)

Arguments

  • text -string- Textfield string
  • sep -char- element separator in string
  • modifier_map -dictionary- mapping of comparison strings to 1-char comparison. Default: {'!=': '!', '==': '=', '>=': '≥', '=>': '≥', '<=': '≤', '=<': '≤'} `

Return

  • List of 3 element lists

Examples

' anna > 1.70, norbert != 900, cindy <= 1.65'

-> [['anna', '>', 1.7], ['norbert', '!', 900.0], ['cindy', '≤', 1.65]]

Metadata

Release files for textfield-parser 0.0.6

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

Source distribution (sdist)

Source distribution for textfield-parser 0.0.6
File Size Uploaded
textfield_parser-0.0.6.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for textfield-parser 0.0.6
File Interpreter ABI Platform
textfield_parser-0.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / textfield_parser-0.0.6.tar.gz

Download URL textfield_parser-0.0.6.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
aff2861b7c4674cbd82823f9969fb7b94069f1ab17184907063d8a4c23a767c9
BLAKE2b-256 checksum
How to use checksums
2f4dfad6e8b798853814a9e5c40107d9a8d0dbd216b91aa40145321b5c2797c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

Release files / textfield_parser-0.0.6-py3-none-any.whl

Download URL textfield_parser-0.0.6-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b94eec3a78802ddfdb9530cdd763271e56081a28d3b3b24d84904510aca3a04
BLAKE2b-256 checksum
How to use checksums
28df72e7dabcd49dc27a1559d56356f2e49b6207dcd624d211046a01c0f915b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

Release history Release notifications | RSS feed

0.0.29

2 release files

0.0.28

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.16

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

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