Cell Parser

Tools for parsing the table based on regular expressions.

class tabledataextractor.table.parse.CellParser(pattern)[source]
Parameters:pattern (str) – Regular expression pattern which defines the cell parser. Use grouping, since matching strings will be returned explicitly.
cut(table, method='match')[source]

Inputs a table and yields a tuple with the index of the next matching cell, as well as a string that is obtained from the original string by cutting out the match string.

Parameters:
  • method (str) – search, match or fullmatch; see Python Regular expressions
  • table (numpy.array) – Input table to be parsed, of type ‘numpy.ndarray’
Yield:

(int, int, str) with index of cells and the strings of the groups that were matched

parse(table, method='match')[source]

Inputs a table and yields a tuple with the index of the next matching cell, as well as the string that was matched.

Parameters:
  • method (str) –

    search, match or fullmatch; Python Regular expressions

  • table (numpy.array) – Input table to be parsed
Yield:

(int, int, str) with index of cells and the strings of the groups that were matched

replace(table, repl, method='match')[source]

Inputs a table and yields a tuple with the index of the next matching cell, as well as a string that is obtained from the original string by cutting out the match string and replacing it with another string.

Parameters:
  • method (str) –

    search, match or fullmatch; see Python Regular expressions

  • table (numpy.array) – Input table to be parsed
  • repl (str) – Replacement string that will be included instead of the patters
Yield:

(int, int, str) with index of cells and the strings of the groups that were matched

class tabledataextractor.table.parse.StringParser(pattern)[source]
Parameters:pattern (str) – Regular expression pattern that defines the string parser.
cut(string)[source]

Inputs a string and returns the same string with the pattern cut out

Parameters:string (str) – Input string
Returns:string with pattern cut out
parse(string, method='match')[source]

Inputs a string and returns True if pattern matches.

Parameters:
Returns:

True/False