Helpers
User-facing convenience functions available via aitaem.helpers.
load_csvs_to_duckdb
aitaem.helpers.csv_to_duckdb.load_csvs_to_duckdb
load_csvs_to_duckdb(csv_path: str | Path, db_path: str | Path, overwrite: bool = True) -> IbisConnector
Load one or more CSV files into a DuckDB database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_path
|
str | Path
|
Path to a single CSV file or a directory containing CSV files. For directories, only top-level CSV files are processed. |
required |
db_path
|
str | Path
|
Path where the DuckDB database file will be written. |
required |
overwrite
|
bool
|
If True (default), existing tables with the same name are replaced. If False, rows from the CSV are appended to existing tables; tables that do not yet exist are created. |
True
|
Returns:
| Type | Description |
|---|---|
IbisConnector
|
An IbisConnector connected to the database at db_path. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If csv_path does not exist. |
ValueError
|
If csv_path points to a single file whose stem is not a valid table name. |