Skip to main content

Parsing Textfields

Project description


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


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)`


  • 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']


  • List of parsed parameters


**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']


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

def read_map(text, sep=',')


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


  • dictionary of parsed parameters


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

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


Reads a json formatted string and return a dictionary


  • text -string- json-string


  • dictionary of json


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'}}


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)


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


  • List of 3 element lists


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

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

Project details

Download files

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

Files for textfield-parser, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size textfield_parser-0.0.6-py3-none-any.whl (4.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size textfield_parser-0.0.6.tar.gz (3.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page