Input/Output tools (dccd.tools.io)¶
Tools and object to load, append and save different kind of database.
- class IODataBase(path='./', method='csv')[source]¶
Object to save a pl.DataFrame into different kind/format of database.
- Parameters:
- pathstr, optional
Path of the database, default is ‘./’ (current directory).
- method{‘DataFrame’, ‘SQLite’, ‘CSV’, ‘Excel’, ‘parquet’, ‘PostgreSQL’, ‘Oracle’, ‘MSSQL’, ‘MySQL’}
Format of database, default is CSV.
- Attributes:
- pathstr
Path of the database.
- methodstr
Kind/format of the database.
Methods
save_as_dataframe(new_data[, name, ext])Append and save new_data as a pickle binary file.
save_as_sql(new_data[, table, name, ext, ...])Append new_data into a SQL database via ADBC (PostgreSQL, MySQL, …).
save_as_sqlite(new_data[, table, name, ext])Append new_data into a SQLite table (stdlib sqlite3, no extra deps).
save_as_csv(new_data[, name, ext])Append new_data to a CSV file (header written once).
save_as_excel(new_data[, name, sheet_name, ext])Append new_data to an Excel file (requires openpyxl).
save_as_parquet(new_data[, name, ext, ...])Append new_data to a Parquet file.
__call__(new_data, **kwargs)Append and save new_data in the configured format.
- save_as_csv(new_data, name=None, ext='.csv')[source]¶
Append new_data to a CSV file (header written once).
- save_as_dataframe(new_data, name=None, ext='.dat')[source]¶
Append and save new_data as a pickle binary file.
- save_as_excel(new_data, name=None, sheet_name='Sheet1', ext='.xlsx')[source]¶
Append new_data to an Excel file (requires openpyxl).
Warning
Slow method, not recommended for large datasets.
- save_as_parquet(new_data, name=None, ext='.parquet', compression='snappy')[source]¶
Append new_data to a Parquet file.