Skip to content

Project 3 — Deep-dive into csv-llm-shared

Audience: students who finished Project 1 or Project 2 and want to understand and extend the shared library that powers both. Also anyone who needs a reusable CSV-to-SQLite-to-dashboards pipeline for another domain.

Level · IntermediateDuration · ~2 hoursChapters · 8Stack · pure Python (pandas, plotly, pyyaml, sqlite3)

csv-llm-shared is the library that Projects 1 (Ollama) and 2 (OpenAI) both import. It contains zero UI code, zero LLM code, zero secrets. Just the data-engineering pipeline:

csv-llm-shared/
├── __init__.py
├── ingest.py ← read CSV → DataFrame (chapter 02)
├── normalize.py ← DataFrame → clean DataFrame (chapter 03)
├── db.py ← DataFrame → SQLite + safe_query (chapter 04)
├── categorize.py ← rules + LLM fallback (chapter 05)
├── dashboards.py ← Plotly figures (chapter 06)
├── smoke_pipeline.py ← end-to-end verification (chapter 07)
├── requirements.txt
├── category_rules.yaml
└── data/
└── data1-anonymized.csv ← demo CSV (also shipped in csv-llm-ollama/data/)

When you have two apps (Ollama + OpenAI) sharing 95% of their code, you have three options:

  1. Copy-paste the shared code into both. (Bad: drift over time.)
  2. One app imports from the other. (Bad: tangles the two apps.)
  3. Extract a shared library both apps depend on. (Good.)

That’s option 3. Each app is now lean (~300 lines of UI + LLM glue), and the heavy data work lives in one place that can be tested independently.

By the end of this project you’ll be able to:

  • Read any new bank CSV by adding a few entries to HEADER_ALIASES.
  • Normalize dates and amounts robustly across locales.
  • Query a SQLite database safely from untrusted SQL (LLM-generated).
  • Categorize uncategorized transactions with a rules+LLM hybrid.
  • Build 4 reusable Plotly figures from a single DataFrame.
  • Verify an entire pipeline in one command with smoke_pipeline.py.
  • Extend the library to your own use case (medical records, sales data, anything CSV-ish).
#ChapterDurationType
01Why a shared library8 minTheory
02ingest.py — multi-bank reader15 minCode
03normalize.py — dates, signs, dedup12 minCode
04db.py — SQLite + safe_query18 minCode
05categorize.py — rules + LLM12 minCode
06dashboards.py — Plotly figures15 minCode
07smoke_pipeline.py — end-to-end test10 minHands-on
08Extending for a new CSV format15 minCode
  • Python 3.9+ and the standard pandas/plotly/pyyaml stack.
  • The csv-llm-shared/ repo cloned locally (git clone https://github.com/inskillflow/csv-llm-shared.git).
  • No Streamlit, no Ollama, no OpenAI required for chapters 01–08 (except chapter 05 which optionally uses an LLM).
  • Linear (recommended): 01 → 08. About 2 hours.
  • Module-focused: pick the module you want to understand (e.g. just chapter 04 for the SQL safety layer).
  • Building your own: 01 → 02 → 03 → 08 (skip the dashboards and categorization until you need them).

← Coming from Project 1 or Project 2? Everything you used imported lives in here.

Start with chapter 01 →