Skip to content

Excel Data Handling

connectx.excel

read

Reads a CSV file and returns it as a Polars DataFrame with the given options.

Parameters:

Name Type Description Default
source str

source filename

required
required bool

generate exception if no files was found and required is True

False
reverse_sort bool

sort in reverse mode if multiple files

False
start int

start from if multiple files

0
stop int

stop to if multiple files

None
header_row int | None

number of header row. None if has no header. Default: 0

0
kwargs

dict, optional Additional keyword arguments to pass to the CSV reader. These can include parameters like 'source', 'separator', 'has_header', 'encoding', etc., which control various aspects of the CSV reading process.

{}

Returns:

Type Description

A Polars DataFrame containing the data read from the CSV file.

write

Writes a Polars DataFrame to a xls/xlsx file with the given options.

Parameters:

Name Type Description Default
df DataFrame

pl.DataFrame. The Polars DataFrame to be written to CSV.

required
file str | Path | IO[str] | IO[bytes] | None

File path or writable file-like object to which the result will be written. If set to None (default), the output is returned as a string instead

None
transform callable

(optional) A transformation function to apply to the data before loading. Default is None.

None
picklist dict

(optional) A dictionary used for mapping or lookup during the load process. Default is None.

None
create bool

(optional) A boolean value for create action. Default is False.

False
kwargs

dict, optional Additional keyword arguments to pass to the CSV writer. These can include parameters like 'separator', 'quote_char', etc., which control various aspects of the CSV writing process.

{}

Returns:

Type Description

Workbook