Track 8 · Lesson 9 of 11
Missing, empty and broken files
Handle files that are missing, empty, malformed or in an unexpected encoding, so one bad input does not stop the whole program.
You will be able to
- Catch FileNotFoundError with a small try/except and fall back to a sensible default
- Recognise completely empty and header-only files and treat them correctly
- Skip and count rows whose values cannot be converted, instead of crashing
- Recover from broken JSON and from files saved in a legacy encoding
Included with a Formula Quest membership
It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.
View Formula Quest memberships
Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.