parse_keyval¶
-
privex.helpers.common.
parse_keyval
(line: str, valsplit: str = ':', csvsplit=',') → List[Tuple[str, str]][source]¶ Parses a csv with key:value pairs such as:
John Alex:Doe,Jane Sarah:Doe
Into a list with tuple pairs (can be easily converted to a dict):
[ ('John Alex', 'Doe'), ('Jane Sarah', 'Doe') ]
By default, uses a colons
:
to split the key/value, and commas,
to terminate the end of each keyval pair. This can be overridden by changing valsplit/csvsplit.- Parameters
- Return List[Tuple[str,str]] parsed_data
A list of (key, value) tuples that can easily be casted to a dict()