Python Quest

Learning map · Track 15 · advanced

Automation and Practical Python

Every office has jobs that eat an hour a week and need no judgement at all: sorting a downloads folder, pasting ten branch exports into one spreadsheet, checking timesheets for impossible hours, rebuilding the same monthly summary, emailing it to the same people. This track teaches you to hand that work to Python safely. You will organise folders with pathlib and shutil, merge CSV exports whose columns arrive in different orders, validate rows and produce error reports, render text, Markdown and HTML reports from templates, and turn scripts into proper command-line tools with argparse, configuration files and logging. Along the way you will compute due dates and business days, write cron lines, retry flaky steps with backoff and make every script safe to run twice.

It is written for learners who already know files, CSV and JSON, text processing, errors, modules, classes and testing. The emphasis throughout is on habits that keep automation trustworthy: a dry run before every change, never deleting or overwriting without a check, logging what happened, and designing runs to be idempotent. Exercises run in a real (virtual) working folder, so your programs genuinely create folders, move and rename files and write reports, and the grader inspects the results, including the awkward cases: empty folders, name collisions, bad rows and half-finished runs. Scheduling, sending email and network calls cannot run in the browser, so those parts are shown honestly as commands for your own computer while the code that builds them is graded. The track ends with a mini project that automates a complete monthly operations report.

By the end of this track you can

  • Plan automation safely with dry runs, collision checks, backups and idempotent re-runs, and organise folders of files with pathlib and shutil
  • Combine many CSV exports with different column orders, deduplicate records and validate them against business rules with a clear error report
  • Generate text, Markdown and HTML reports from templates with correct escaping, and build (not send) email messages with attachments
  • Turn scripts into command-line tools with argparse, main() and exit codes, driven by JSON, INI or TOML configuration with defaults and validation
  • Log automation runs to files, compute due dates, business days and cron schedules, and recover from failures with retries and partial-failure reports

Lessons

  1. 1Thinking in automationDecide what is worth automating, describe its inputs and outputs, and build scripts that plan before they act.35 min · 3 exFree
  2. 2Organising filesList, filter and sort files with pathlib, then move them into folders by type or date with dry runs and collision-safe names.50 min · 4 exMembers
  3. 3Combining exportsMerge many CSV exports into one file, even when their columns arrive in different orders and spellings, and remove duplicate records.50 min · 4 exMembers
  4. 4Validation reportsCheck every row of every file against business rules, collect all the problems with their location, and report them as CSV and Markdown.50 min · 4 exMembers
  5. 5Generating reportsProduce aligned text, Markdown and HTML reports from data with f-strings and string.Template, escape HTML correctly, and package a report as an email message.55 min · 4 exMembers
  6. 6Command-line scriptsTurn automation scripts into command-line tools with argparse, a testable main() function and meaningful exit codes.50 min · 4 exMembers
  7. 7Configuration filesMove paths, thresholds and switches out of the code into JSON, INI or TOML configuration files, with sensible defaults and validation.50 min · 4 exMembers
  8. 8Logging for automationRecord what unattended scripts do with the logging module: levels, named loggers, formats, log files and reading logs back.50 min · 4 exMembers
  9. 9Dates and schedulesCompute due dates, business days and month-end dates with datetime, keep date logic testable, and express recurring schedules as cron lines.50 min · 4 exMembers
  10. 10Resilient automationMake scripts survive the real world: retry transient failures with backoff, re-run safely with state files, and finish the batch when one item fails.55 min · 4 exMembers
  11. 11Mini project: the monthly operations reportAutomate a complete monthly report from messy branch exports: collect, combine, validate, report and log, one milestone at a time.90 min · 5 exMembers