This project mirrors real data-engineering work: a small ETL pipeline that extracts data from a CSV, transforms (cleans and reshapes) it, and loads it into a SQLite database. It ties together files, cleaning, databases and logging.
The three stages
- Extract — read rows from a CSV (or an API).
- Transform — clean values, convert types, filter, derive new fields.
- Load — insert into a SQLite table with parameterised queries.
- Log progress and skip bad rows without crashing the whole batch.
Pipeline scaffold
import csv, sqlite3, logginglogging.basicConfig(level=logging.INFO)def extract(path):with open(path, newline="") as f:yield from csv.DictReader(f) # stream rows lazilydef transform(row):return {"name": row["name"].strip().title(),"package": float(row["package"])} # may raise → caught belowdef load(rows, db="out.db"):conn = sqlite3.connect(db)conn.execute("CREATE TABLE IF NOT EXISTS students(name TEXT, package REAL)")ok = 0for row in rows:try:clean = transform(row)except (KeyError, ValueError) as e:logging.warning("skipping bad row: %s", e)continueconn.execute("INSERT INTO students VALUES (?, ?)",(clean["name"], clean["package"]))ok += 1conn.commit(); conn.close()logging.info("loaded %d rows", ok)load(extract("students.csv"))
Stretch goals
Add a "de-duplicate" step, make it idempotent (re-runnable without double-inserting), or swap the CSV source for an API extract.
Key takeaways
- 01ETL = Extract, Transform, Load — a core data-engineering pattern.
- 02Combines files/CSV, cleaning, databases and logging.
- 03Stream rows lazily (yield) so large files fit in memory.
- 04Parameterised inserts keep the load step safe from injection.
- 05Handle bad rows gracefully so one error does not stop the batch.
