Filesystem & Data Pipelines Coding Clinic.
Eight original Python challenges: safe pathname resolution, real UTF-8 file reads, CSV structures, duplicate rows, JSON validation, deterministic serialization, staged output and a complete fictional inventory analyzer.
Where files go: These exercises use real Python pathlib, tempfile, csv and json in a browser-isolated virtual filesystem, not your Windows or macOS files. Changes are intentionally temporary and never access customer systems. Run allows experimentation; Check evaluates the stated example and additional cases.
For an end-to-end local exercise, return to the guarded CSV-to-JSON project after completing the clinic.
Write it. Run it. Understand it.
Work with pathlib, real temporary Python files, CSV/JSON schema validation and staged reports inside the isolated browser filesystem.
Resolve a file inside an approved folder
Write safe_file(root, filename) using pathlib.Path. Return a resolved Path only when filename is a relative file path inside root, has no '..' path component, isn't the root directory itself, and resolves inside the root. Otherwise return None. For root '/northstar/incoming' and 'inventory.csv', print the complete resolved path. The grader changes folder names and tries traversal, absolute and sibling-prefix paths. Don't create or delete any files.
/northstar/incoming/inventory.csvTry solving it before asking for help. Hints never show a completed program.
Your printed output and errors will appear here.
Run the code, then step through the executed lines to watch variable values change.
