Day 96 of 100 Days Coding Challenge: Python
Today was less about writing shiny new features and more about wrestling with files until the app behaved like it did back on Day 19. After nearly four hours of tinkering yesterday, I had to step away—full-time jobs and real life have a way of enforcing time limits. But I was annoyed at myself for one thing: forgetting to commit to GitHub. Again.
This project has grown into a filing labyrinth, the kind where one wrong turn in data/ leaves you staring at errors that make no sense. The safest way to preserve it is to both recreate the file structure and push to GitHub. Of course, I did neither at first. Nineteen days of work, sometimes 4–5 hours at a stretch, left hanging by a thread. Thankfully, I managed to recover everything, lock it with a password, and—finally—commit it to GitHub. Lesson learned.
Today’s Motivation / Challenge
Why does this matter? Because all the code in the world won’t help if your files don’t point to the right place. Data seeds are the backbone of this project: civilizations, events, and sources all live in CSVs. If your app can’t find them, it’s like trying to read a book without the pages.
Purpose of the Code (Object)
The code reconnects the app to its seed files—civilizations.csv, events.csv, and sources.csv. These files feed the database with initial data, ensuring the app has something to display. Without them, the app just spins its wheels and looks confused. By linking everything properly, the app can reload cleanly whenever you restart it.
AI Prompt
We will work on the Import.
Creating the link to the correct data seeds:
- data/seeds/civilizations.csv
- data/seeds/events.csv
- data/seeds/sources.csv
Functions & Features
- Import civilizations, events, and sources from CSV seed files.
- Ensure the app database initializes with correct data.
- Reconnect app logic to seed files if paths are broken.
Requirements / Setup
You’ll need:
- Python 3.11
Installs:
pip install sqlmodel
Minimal Code Sample
import pandas as pd
civs = pd.read_csv(“data/seeds/civilizations.csv”)
events = pd.read_csv(“data/seeds/events.csv”)
sources = pd.read_csv(“data/seeds/sources.csv”)
Reads the seed CSVs into dataframes for use in the app.
The Civilization Timeline Builder
Notes / Lessons Learned
When you hit a problem importing data, the best thing you can do is stay calm and check filenames line by line. My biggest mistake came from an earlier definition error—I had renamed a file, recreated seeds, and left a trail of confusion. AI didn’t make it worse, but long chats with shifting memory meant old names and new names occasionally got tangled. Programming is like that: fragile, literal, unforgiving.
At one point, I even had the wrong database URL: sqlite:///./data/app.db instead of the correct sqlite:///./data/civ.db. One tiny typo, and the whole app refused to recognize my seeds. Reloading Streamlit without the right database path? A guaranteed disaster.
In the end, a fresh brain helped more than any clever trick. I reconnected the seed files, corrected the database path, and the app sprang back to life. Programming, I’ve realized, is 50% code, 50% precision—and 100% patience.
Optional Ideas for Expansion
- Add validation scripts to confirm all seed files exist before the app runs.
- Build a “seed reloader” button in the UI for quick fixes.
- Let users upload their own seed CSVs to extend the dataset.
