Python Automation
Schedule Scripts, Process Files and Spreadsheets, Log Every Error and Keep Jobs Running Without You
-
- $24.99
-
- $24.99
Publisher Description
A script that works while you watch it is the easy part. The hard part is the night it runs alone: the export that grows a second header line, the computer that was asleep at 3 a.m., the job that is stopped halfway and started again and writes every line twice. Nobody notices until the quarterly review. This guide covers the parts that decide whether a script survives its first bad night.
It starts with the arithmetic of whether a chore is worth automating, then covers the work itself: sorting and archiving files without losing any, cleaning spreadsheet exports with exact money arithmetic, summarising logs, and calling other programs safely. After that comes the reliability layer: reading schedule lines before you trust them, logging that answers five questions at 9 a.m., a heartbeat that reports a job that never ran, retries, locks, results that survive a rerun, and settings and secrets kept out of the code. Three complete jobs are assembled on a shared base and tested end to end. Every chapter ends with one action you can take on your own files that day.
Inside you will find:
• A break-even calculator, a table that shows whether its verdict survives bad luck, and a one-page job card to fill in before any code
• A tidy-up script with a dry run, a collision rule and an undo log, and an archive routine that proves the zip before it moves anything
• A cleaner for messy exports that rejects bad rows with line numbers and proves that every row is accounted for
• A due-time calculator for schedule lines, a catch-up rule for sleeping computers and a stale-heartbeat checker
• Retry with back-off, a lock file with stale detection, a ledger and a graceful stop, shown surviving a crash in the middle
• A settings loader that reports every problem at once, and a filter that keeps secrets out of logs
• Three finished jobs (a drop-folder processor, a daily digest and a verified backup) with eight automated tests
Everything uses only what ships with Python 3.10 or newer, and every listing comes with its real printed output. The examples run against folders you create yourself; nothing touches real accounts or sites. Written as general information. If a job handles records you must keep by law or contract, or personal data about other people, agree the plan with whoever is responsible for that data before you schedule anything.