pycognaize.common.numeric_parser.NumericParser

class NumericParser(raw)[source]

Bases: object

Parser for any kind of text input into a corresponding format. Numeric data is assumed to be valid and clean. Use NumericColumnFormatter for validating your data.

Parameters:

raw (str)

Methods

infer_sign

Infer the sign of the number either with brackets or a trailing minus sign

is_numeric

Determines if the text is a representation of a numeric value

parse_numeric

Parse the raw data, and return parsed numeric value and get the numeric, separator and value type of the raw data

parse_raw_numeric

Used for parsing raw text without getting any context from the column

parse_regular_float

Parse Like a regular float number

parse_regular_float_with_semicolon

Parse Like a regular float number with semicolon

remove_dash_sign

remove_sign_parentheses

strip_value

Strip non-numeric characters from a string representing a number :param str text: Input string representing a number :return: String with stripped non-numeric characters :rtype str:

Attributes

REGEX_NO_ALPHANUM_CHARS

brackets

delimiters

numeric

single_white_space_regex

infer_sign()[source]

Infer the sign of the number either with brackets or a trailing minus sign

is_numeric()[source]

Determines if the text is a representation of a numeric value

Return type:

bool

Returns:

True if the raw text corresponds to numeric representation

parse_numeric()[source]

Parse the raw data, and return parsed numeric value and get the numeric, separator and value type of the raw data

Return type:

Union[int, float]

Returns:

Parsed float or int value

parse_raw_numeric()[source]

Used for parsing raw text without getting any context from the column

Return type:

Union[int, float]

parse_regular_float()[source]

Parse Like a regular float number

parse_regular_float_with_semicolon()[source]

Parse Like a regular float number with semicolon

static strip_value(text)[source]

Strip non-numeric characters from a string representing a number :param str text: Input string representing a number :return: String with stripped non-numeric characters :rtype str:

Parameters:

text (str)