data_helper.parse module

String parse wrapper functions to streamline common use cases

data_helper.parse.list_filter(pattern, iter, flags=0)[source]

Use regular expression patterns to filter a list of strings

Parameters:
  • pattern (str|list) – String or list of strings of regular expression patterns.
  • iter (list) – List of strings to be filtered. Can be any iterable object that can be iterated in a for-loop.
  • flags (int) – See re
Returns:

List of matching strings.

Return type:

list

data_helper.parse.str_split_caps(s, trim=True)[source]

Split a string on capital letters

Parameters:
  • s (str) – The string to be divided. Value type is converted to string.
  • trim (bool) – Remove whitespace. Defaults to True.
Returns:

List of strings, each starting with a capital letter, in the same order as they appear in the string.

Return type:

list

data_helper.parse.str_split_size(s, n=None)[source]

Split a string by length

Parameters:
  • s (str) – The string to be divided. Value type is converted to string.
  • n (int) – Length of string per list item. Value type is converted to integer.
Returns:

List of strings, each the same size, in the same order as they appear in the string.

Return type:

list