Gemini CLI and a Local Notebook for Cleaner CSVs
Gemini CLI and a Local Notebook for Cleaner CSVs
My preferred data-cleaning setup in 2026 is deliberately boring: an editor, Gemini CLI in a terminal, and a local Jupyter notebook. The CLI helps inspect code and propose transformations; the notebook makes assumptions visible through counts, samples, and plots. Neither gets to silently rewrite the source data. The useful pattern is not “clean this CSV.” It is “propose one transformation, explain its consequences, and give me a test.”
Keep the notebook local and the raw CSV immutable
I start with data/raw, data/processed, notebooks, src, and tests directories. Raw inputs stay untouched and outside version control when they contain sensitive records. I record their checksums, export dates, and expected schema in a manifest. That gives every later result an identifiable starting point instead of a mysterious file called customers_final_v3.csv.
A local notebook does not automatically mean private AI assistance. Anything supplied to a remote model can leave the machine, including tool output. Before starting Gemini CLI, I restrict its accessible workspace and approval settings, exclude secrets and raw datasets, and prepare a synthetic sample with the same schema and failure patterns.
- Replace identifying values with synthetic examples before requesting transformation advice.
- Inspect tool permissions before allowing commands that read additional files.
- Treat spreadsheet cells as untrusted data, never as executable instructions.
Ask Gemini CLI for a cleanup plan before edits
My first prompt describes the columns, intended output types, and known defects. For example: “customer_id is an identifier, not a number; amounts use mixed separators; timestamps include offsets. Propose ordered cleanup steps and ambiguous cases. Do not modify files.” This catches the classic mistake of losing leading zeros before anyone writes a transformation.
Then I request one small function at a time in src/cleaning.py, with tests in tests/test_cleaning.py. Gemini CLI can help draft both, but I review the diff before running anything. An instruction inside a CSV saying to upload files or change permissions is data contamination, not permission to act.
Use notebook cells as executable cleanup checkpoints
The notebook imports the cleaning functions instead of hiding production logic in twenty exploratory cells. Each stage shows row counts, null counts, duplicate counts, and representative rejected values. I keep parsing failures in a quarantine table with a reason column, rather than quietly coercing everything into missing values.
For mixed dates, I require an explicit source convention before parsing ambiguous values such as 03/04/2026. For money, I preserve the original text and choose decimal arithmetic or integer minor units according to the business rules. For joins, I check key uniqueness and expected cardinality before accepting the merged result.
- Assert that identifier normalization preserves meaningful leading zeros and distinctions.
- Check that deduplication uses an explicit, deterministic winner selection rule.
- Verify that running cleanup twice produces the same normalized output.
- Reconcile input rows against accepted, rejected, and deliberately removed records.
Separate Gemini CLI configuration from notebook API calls
I keep terminal-agent configuration separate from notebook experiments. Fluxo gives me one key and one base URL, https://api.fluxorelay.com, across Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Qwen, Grok, and more. It works with Claude Code, Codex, Gemini CLI, and any OpenAI SDK. That does not mean every client uses identical configuration: I follow the current Gemini CLI integration instructions rather than assuming an OpenAI SDK base URL setting configures the CLI.
For a notebook-side comparison, I might send the same sanitized schema question to Gemini 3.1 Pro and GPT-6 Astra. I keep credentials in environment variables and save neither keys nor sensitive responses in notebook outputs. Fluxo bills per real token, including cache reads and writes, with no monthly fee, so compact context and small samples remain useful habits.
Ship a reproducible cleanup run, not notebook state
Before merging, I restart the kernel, run every cell, execute the tests, and regenerate outputs from immutable inputs. The review includes code changes, a quality summary, dependency versions, and counts of quarantined records. Model suggestions are proposals; reproducible checks decide whether they ship.
If this fits your workflow, you can create a Fluxo account for a small, sanitized trial. Users also earn a referral share when people they invite pay. For help, leave a note on the contact page after signing in.