Giter Site home page Giter Site logo

python-etl-boilerplate's Introduction

Boilerplate for Python ETL Pipeline

This is a boilerplate Python repository is a Python ETL (Extract, Transform, Load) pipeline for ingesting data. The pipeline reads in a .csv file, melts the columns except date and time, and writes them to different PostgreSQL tables.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

You will need Python 3.6 or later to run this project. You will also need PostgreSQL installed on your machine.

Getting Started

  1. Set up your PostgreSQL credentials in a .env file in the root directory of the project. The file should have the following format:
POSTGRES_USER=yourusername
POSTGRES_PASSWORD=yourpassword
  1. Set up your PostgreSQL configuration in the config.json file. The file should have the following format:
{
  "database": "analytics_db",
  "host": "localhost",
  "port": 5432,
  "data": { // The data object contains the configuration for each data source.
    "dry_bulb": {
      "vector": false, // Set to true if the data source contains vector data.
      "source": "./input/test.csv", // The path to the data source.
      "columns": ["date", "time", "station_id", "dry_bulb"], // The columns of data source.
      "unit": "[deg C]", // The unit of the data source. This is removed from the column name.
      "table": "aws_drybulb_1_min" // The name of the PostgreSQL table to write to.
    }
  }
}


Usage

To run the project, navigate to the src directory and run the main.py script:

python ./src/main.py

To run the script without writing to the database, use the --dry-run flag:

python ./src/main.py --dry-run True
usage: main.py [-h] [--dry-run IS_DRY_RUN]

optional arguments:
  -h, --help            show this help message and exit
  --dry-run IS_DRY_RUN  Run the ETL pipeline without writing to the database.

Project Structure

  • src/main.py: Main script that runs the ETL pipeline.
  • src/etl.py: Contains the ETL pipeline functions.
  • src/config.py: Reads the configuration from config.json and the PostgreSQL credentials from the .env file.
  • src/logger.py: Sets up the logging configuration.
  • config/config.json: Stores the configuration for the PostgreSQL database.
  • .env: Stores the PostgreSQL username and password.

Author

Wong Songhan

python-etl-boilerplate's People

Contributors

songhan89 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.