pypeliner.utils.csv_utils

CSV utils contains utilities to read csv files

Functions

convert_string_to_number(→ Union[int, float, str])

A function to convert an str typed number to a number, if the passed string

convert_row_values_to_numbers(→ List[Union[int, float, ...)

A function to convert a csv file row string values to numbers if possible.

Module Contents

pypeliner.utils.csv_utils.convert_string_to_number(string: str) int | float | str

A function to convert an str typed number to a number, if the passed string is a text and not a number, then the same string is returned. Args:

string: the number in a string form

Returns:

A number (int or a float).

pypeliner.utils.csv_utils.convert_row_values_to_numbers(row: List[str]) List[int | float | str]

A function to convert a csv file row string values to numbers if possible.

e.g:

input: [“1”, “2”, “a”, “b”] output: [1, 2, “a”, “b”]

Args:

row: a row from a csv file.

Returns:

the row with number values instead of strings