Skip to main content

from nrcan_etl_toolbox.etl_toolbox.reader.source_readers import ExcelReader

NRCAN ETL Toolbox

codecov CI

Pour la version française de ce document, consultez README-fr.md.

etl-toolbox is a Python toolkit designed to simplify Extract, Transform, and Load (ETL) data processes. This modular toolkit offers several specialized components for different aspects of ETL workflows.

Components

etl_logging

Specialized logging module for ETL processes, allowing simple configuration and efficient log analysis.

etl_toolbox

Collection of tools for reading data from various sources. It includes readers for different file formats and databases, facilitating data integration in ETL processes:

  • Data Readers: CSV, Excel, GeoPackage, JSON, PostGIS, Shapefile

database

Interfaces and ORM for interacting with different database systems:

  • Database Interfaces: Abstract object handlers for database interactions
  • ORM: Object-relational mappings to simplify data access

Installation

Install the package via Poetry:

poetry install

Or by creating a distribution:

poetry build
pip install dist/nrcan_etl_toolbox-*.whl

Usage

Logging Module (etl_logging)

from nrcan_etl_toolbox.etl_logging import CustomLogger

logger = CustomLogger(name="Test Logger", level='INFO'
                      ,logger_type='verbose',
                      logger_file_name='test_logger.log')

# Logging messages
logger.info("Starting ETL process")
logger.debug("Technical details", extra={"data": {"items": 100}})
logger.error("Processing error", exc_info=True)

Data Readers (etl_toolbox)

from nrcan_etl_toolbox.etl_toolbox.reader import ReaderFactory
from nrcan_etl_toolbox.etl_toolbox.reader.source_readers import ExcelReader

# Creating a CSV reader
csv_reader = ReaderFactory(input_source="data.csv")
data = csv_reader.data

# Creating a Shapefile reader
shp_reader = ReaderFactory(input_source="data.shp")
geo_data = shp_reader.data

# Creating a PostGIS reader
postgis_reader = ReaderFactory(input_source="postgresql://user:password@host:port/database", # Use the connection string for your database
                               table_name="table_name",
                               schema="schema_name")
geo_data = postgis_reader.data

# Creating an Excel reader
reader = ReaderFactory(input_source="data.xlsx")
# Get the Reader object
excel_reader : ExcelReader = reader.reader
# If excel file contains multiple sheets, 
# data will be a dictionary with sheet names as keys and dataframes as values
data = excel_reader.dataframe 
# data = {'Sheet1': df1, 'Sheet2': df2}
# To read a specific sheet, use the sheet_name parameter
data = excel_reader.read_sheet('Sheet1')
# data = df1

Database Interface

# TODO: Complete documentation.
from nrcan_etl_toolbox.database.interface import AbstractDatabaseHandler
# Usage example to be documented

Development

To contribute to the project, install development dependencies:

poetry install --with dev

Run tests with:

pytest

Project Structure

nrcan_etl_toolbox/
├── database/               # Database interactions
│   ├── interface/          # Abstract interfaces for databases
│   └── orm/                # Object-relational mappings
├── etl_logging/            # ETL logging module
└── etl_toolbox/            # Main ETL tools
    └── reader/             # Data source readers
        └── source_readers/ # Specific reader implementations

Authors

For questions or suggestions, please use the project's GitHub issues.

Metadata

Release files for nrcan-etl-toolbox 0.2.26

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nrcan-etl-toolbox 0.2.26
File Size Uploaded
nrcan_etl_toolbox-0.2.26.tar.gz 21.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nrcan-etl-toolbox 0.2.26
File Interpreter ABI Platform
nrcan_etl_toolbox-0.2.26-py3-none-any.whl Python 3 none any Details

Total release size: 50.9 kB

Release files / nrcan_etl_toolbox-0.2.26.tar.gz

Download URL nrcan_etl_toolbox-0.2.26.tar.gz
Size 21.4 kB
Tags Source
SHA-256 checksum
How to use checksums
222dd04724618ba6547a2acfa6395f363df39e3960ff3912553a8d34033aff2b
BLAKE2b-256 checksum
How to use checksums
c686d43aec2e4681df589f6a79d74f3a23187ff2e8ef0ad6c687e7e41fcb1b9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / nrcan_etl_toolbox-0.2.26-py3-none-any.whl

Download URL nrcan_etl_toolbox-0.2.26-py3-none-any.whl
Size 29.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5192dc57404343b8f502885bcc7a2a26dfd8b50503c8de9fb8c7cbd69e8c5119
BLAKE2b-256 checksum
How to use checksums
5a621a2ac283073e5952205cd1f5308176f9f5e333e644febde9cb9dc0fb3d12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.2.26 This release

2 release files

0.2.25

2 release files

0.2.21

2 release files

0.2.20

2 release files

0.2.15

2 release files

0.2.10

2 release files

0.2.9

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.55

2 release files

0.1.53

2 release files

0.1.52

2 release files

0.1.50

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page