pypeliner.readers.bulk_readers.file_readers

File readers module, defines bulk reading for regular text and csv files.

Classes

BaseReader

A base class for readers

FileReader

A reader used to read an entire file.

CSVFileReader

A reader to read a csv file.

Functions

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

class pypeliner.readers.bulk_readers.file_readers.BaseReader

A base class for readers

abstract read() Any

An abstract method that defines reading logic.

Returns:

data to be processed.

pypeliner.readers.bulk_readers.file_readers.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

class pypeliner.readers.bulk_readers.file_readers.FileReader(file_path: str)

Bases: pypeliner.readers.base.BaseReader

A reader used to read an entire file.

Args:

file_path: file directory.

read() str

An abstract method that defines reading logic.

Returns:

data to be processed.

class pypeliner.readers.bulk_readers.file_readers.CSVFileReader(file_path: str, load_titles_row: bool = True, columns_names: List = None, delimiter: str = ',', detect_numbers: bool = True)

Bases: pypeliner.readers.base.BaseReader

A reader to read a csv file.

Args:

file_path: file directory. load_titles_row: read the first line from the file to consider that as the columns names. columns_names: custom column names that will override the csv file existing columns names when load_titles_row is True. delimiter: rows delimiter. detect_numbers: convert string number values to int/float.

read() Dict

An abstract method that defines reading logic.

Returns:

data to be processed.