parse_csv

privex.helpers.common.parse_csv(line: str, csvsplit: str = ',') → List[str][source]

Quick n’ dirty parsing of a simple comma separated line, with automatic whitespace stripping of both the line itself, and the values within the commas.

Example:

>>> parse_csv('  hello ,  world, test')
['hello', 'world', 'test']
>>> parse_csv(' world  ;   test   ; example', csvsplit=';')
['world', 'test', 'example']
Parameters
  • line (str) – A string of columns separated by commas e.g. hello,world,foo

  • csvsplit (str) – A character (or several) used to terminate each value in the list. Default: comma ,