Code 1, Code 2, ... Success, Final
What struck me in this notebook were the cell titles. They read "Code 1", "collection error: HTML loaded wrong", "success", "final", and "fix", in that order. Crawling isn't finished in one shot. The process of hitting an error, finding the cause, and fixing it stayed in the record.
Setting the Path to Import a Module
Because the working file and the shared module (dbio) lived in different places, I learned to add a path to sys.path.
import sys, os
target_dir = os.path.abspath("../../")
if target_dir not in sys.path:
sys.path.append(target_dir)
from dbio import to_dbHoliday-Handling Logic
Exchange rates are only published on business days. I put guard logic inside the function for when a given date has no data. Along with collecting, I picked up the sense of treating "a day with no data" as part of the normal flow.
Cleaning Then Loading to the DB
I cleaned the raw collection with pandas and stored it into MySQL via the to_db() module function made earlier. Separating collection code from DB I/O code into a module meant I could reuse it in other projects with a single from dbio import to_db.
Takeaway
Key point
The biggest lesson was "don't erase your failures." Keeping the error cells kept me from repeating the same mistake. The notebook itself also explained why the code looks the way it does. It's the same reason I keep this training log.