Replies: 1 comment
-
|
See post #18 for my thoughts on this and the next post. Happy to further discuss the issues raised in that thread. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Paul,
I ran into this: men’s records were fine, but women’s records were missing, while working on WorldRecords.ipynb - Chapter 9.
Root cause
The notebook uses hard-coded table indices:
RECORDS = (0, 2, 4, 5)Wikipedia’s table order has changed, so those indices now point at the wrong tables (often relay-only). This caused women’s records to be incomplete/missing and also caused downstream KeyError/IndexError issues.
Fix (robust for table reordering in WorldRecords.ipynb - Chapter 9)
Instead of fixed indices, pick tables based on the nearby headings (“Long course / Short course” + “Men / Women”) and merge them (Code drop-in replacement for the records-building cell):
Then re-run the json.dump(records, jf) cell to refresh
records.jsonValidate
After re-running the notebook:
Defensive app fix (prevents crashes)
In swimclub.py (def produce_bar_chart()), replace with conditional append:
Why This Works
Headings like “Long course (50m pool)” and “Women” are more stable than table positions, so scraping survives table reordering. It fixes a real breakage (women’s records missing) and replaces brittle table indices with heading-based selection, which should be much more resilient to Wikipedia table reordering over time.
Hope you find this useful.
Regards,
Adrian
Beta Was this translation helpful? Give feedback.
All reactions