csv

Classes

CsvReader

Safe CSV file reader.

CsvWriter

Safe CSV file writer.

class CsvReader[source]

Bases: object

Safe CSV file reader.

static check(path)[source]

Checks that a file has the correct extension and exists.

Parameters:

path (Union[str, Path]) – Path to the file.

Returns:

static read(path, verbose=True)[source]

Reads and parses a CSV file. :type path: Union[str, Path] :param path: Path to the file. :type verbose: Union[bool, int] :param verbose: Verbosity of the method. :rtype: DataFrame :return: DataFrame with CSV content.

Parameters:
  • path (str | Path)

  • verbose (bool | int)

Return type:

DataFrame

class CsvWriter[source]

Bases: object

Safe CSV file writer.

static check(path, overwrite=False)[source]

Checks that a file has the correct extension and verifies that we can overwrite it if it exists.

Parameters:
  • path (Union[str, Path]) – Path to the file.

  • overwrite (bool)

Returns:

static write(df, path, overwrite=False)[source]

Writes DataFrame content into a CSV file.

Parameters:
  • df (DataFrame) – DataFrame with content.

  • path (Union[str, Path]) – Path to the file.

  • overwrite (bool) – Whether to overwrite, in case of an existing file.

Returns: