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.
What this project covers
Section titled “What this project covers”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/)Why a separate library?
Section titled “Why a separate library?”When you have two apps (Ollama + OpenAI) sharing 95% of their code, you have three options:
- Copy-paste the shared code into both. (Bad: drift over time.)
- One app
importsfrom the other. (Bad: tangles the two apps.) - 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.
What you’ll learn
Section titled “What you’ll learn”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).
The 8 chapters
Section titled “The 8 chapters”| # | Chapter | Duration | Type |
|---|---|---|---|
| 01 | Why a shared library | 8 min | Theory |
| 02 | ingest.py — multi-bank reader | 15 min | Code |
| 03 | normalize.py — dates, signs, dedup | 12 min | Code |
| 04 | db.py — SQLite + safe_query | 18 min | Code |
| 05 | categorize.py — rules + LLM | 12 min | Code |
| 06 | dashboards.py — Plotly figures | 15 min | Code |
| 07 | smoke_pipeline.py — end-to-end test | 10 min | Hands-on |
| 08 | Extending for a new CSV format | 15 min | Code |
Prerequisites
Section titled “Prerequisites”- 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).
How to read this course
Section titled “How to read this course”- 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.