Handle errors and work with real files in Python: text, CSV, JSON, paths, and regular expressions.
Everything you have written so far worked on data you typed yourself, which means it has never once been wrong. Real data arrives from somewhere else: a file, a sensor, a colleague's export. It has blank rows, it has the word `n/a` where a number should be, and it is missing entirely about as often as you would expect. This course is about the two skills that go together, handling what goes wrong and reading what comes in. Most courses teach files first and error handling later. This one inverts that on purpose, because every interesting thing about a file is a failure mode: the file is not there, the row is malformed, the number is not a number, the text is not the encoding you assumed. Two sections of exceptions first means every file you open from section 4 onward can be honest about failure from its first line, instead of having error handling retro-fitted once the code already works on perfect input. Everything is built on the Tide Station, a coastal sensor at Portree whose output is messier than anybody would like: a parser that survives bad readings, then one that reports exactly what was wrong, then a writer that always closes, then the readings file itself, then an archive of dated files, then the readings as CSV, then the station config as JSON, then the raw log pulled apart with regular expressions, and finally one report that says what it could read and what it could not. By the end you can take three files somebody else produced and turn them into data you trust, which is most of what a working Python job actually is.
45 Lessons • 53 Practices • 18 Quizzes • 4 Projects · ~10h Total
Not just theory. You finish this course with real work to show.
This is the same in-browser editor every lesson uses. Edit the code, hit Run.
Run code in the browser and see the result immediately. Every lesson works this way.
Stuck? Puff explains the error and nudges you forward, without giving the answer away.
Streaks, diamonds, and certificates. Your progress saves automatically, forever.
Every completed course issues a certificate with a public verification link.
Every certificate has a public verification link employers can check.
One certificate per course. Finish a program and earn its program certificate too.
LinkedIn-ready, with a PDF you can download and attach.
Your programs still only work on data you typed in yourself. This is where the data starts arriving from outside.
You wrap everything in try and hope. This is how to catch the one thing you expected and let the rest through.
CSV in and JSON out is the daily job in both. This is the course where that becomes ordinary.
Python File Handling is free to start, no credit card needed. Some later sections are part of Pro, and finishing every section, including the certificate, needs a Pro plan.
Yes, up to Python Functions. You need comprehensions, dictionaries, and functions with default arguments from day one here. Object-Oriented Python is not required even though it comes earlier in the program: the single class in this course is three lines long and is taught from scratch where it appears.
Yes, and no disk is involved. Python runs inside your browser tab on a real in-memory filesystem, so `open`, `pathlib`, `csv` and `json` all behave exactly as they do on a laptop, and the code you write is unchanged on a real machine. Nothing is ever written to your own computer, and everything you create disappears when you close the tab.
Catch it when you know what to do about it: skip the bad row, use a default, tell the user which file was missing. Let it stop when you do not, because a program that crashes with a clear message is easier to fix than one that quietly carries on with wrong data. This course keeps returning to that choice, starting in section 1.
Enough to read a simple one and write a simple one, which is what section 8 covers. They are how you pull structure out of text that has none, such as a log file or a pasted report. Anything more complicated than a few fields is usually a sign that a proper parser exists for that format, and the section says so.
The Tide Station: a parser that survives bad readings, a writer that always closes, a readings file, a dated archive, a CSV importer, a config round trip, a log parser built on regular expressions, and a full station report as the capstone.
Yes, for this course at 100 percent. It also counts towards the Python Developer program certificate, which issues once every course in that program is complete.
How this course connects to the bigger picture, and what to explore next.
Git from zero: commit, branch, merge, undo, and tag real repositories in a live terminal.
Write object-oriented Python: classes, inheritance, properties, special methods, and dataclasses.
Write real Python in your browser: variables, strings, conditionals, loops, lists, and functions.
Free to start, no credit card required. Write real code from the first lesson and keep your progress forever.
Start Learning Free