Frameworks & Languages
Automating Back-Office Work With Python: Reports, Imports and Scheduled Jobs
Weekly reports built by hand, supplier files reformatted before import, checks someone has to remember: Python turns these into reliable scheduled jobs. Here is how we build automation that validates its input, alerts on failure and keeps running.

Most businesses run on a layer of manual routine that nobody designed: the Monday report built by copying three exports into a spreadsheet, the supplier price file someone reformats before importing, the nightly check that orders reached the warehouse. Each task is small, but together they take hours every week, depend on one person remembering, and break quietly when a column moves. This is the work Python is best at taking off people's desks.
Automation is one of the three areas of our Python, Django and FastAPI development work, alongside web applications and APIs. Here is how we approach it, so the scripts keep working long after the person who asked for them has moved on.
Why Python for Back-Office Work
Python's strength here is its libraries rather than its speed. Almost every format and system a back office touches has a mature, well-maintained package:
- Spreadsheets and files: openpyxl for reading and writing Excel workbooks with their formatting, the standard csv module, and pdfplumber for pulling tables out of PDFs.
- Data shaping: pandas or Polars for joining, grouping and cleaning tabular data.
- Other systems: httpx or requests for REST APIs, SQLAlchemy for databases, paramiko for SFTP drops, and imaplib or the Microsoft Graph API for mailboxes.
- Validation: Pydantic for defining what a valid row looks like and rejecting anything that does not match.
Python is also readable enough that a technically minded person on your team can follow what a script does, which matters for something that touches your finances or stock.
Reports That Build Themselves
Recurring reports are the most common starting point. The pattern is the same whatever the content:
- Pull from the actual systems through their APIs or a read-only database user, not from someone's manual export.
- Calculate in code, with business rules written down once. "Revenue" should mean the same thing in every report.
- Render in the format people already use: an Excel workbook with the familiar layout, a PDF, or an HTML email with the headline numbers in the body.
- Deliver by email, to a shared drive or into a dashboard, at the time people actually need it.
Reports that put heavy load on a live database should run against a replica or outside trading hours. A large query on the same server as checkout is a common cause of slowdowns, as we explain in why sites slow down as they grow.
Imports That Do Not Corrupt Your Data
Imports are where automation can do the most damage, because a bad file loaded silently is worse than no import at all. Every import we build follows the same rules:
- Validate before writing. Check every row against a schema: required columns present, numbers parse, codes exist, dates are dates. Collect all the problems rather than stopping at the first.
- Stage, then apply. Load into a staging table, compare with what is already there, and apply the changes in a single transaction, so a failure halfway leaves nothing half-done.
- Make it idempotent. Running the same file twice must not create duplicates. Use natural keys or a hash of the file to recognise what has already been processed.
- Sanity-check the size of the change. If a price file would change every price, or a stock feed would set half the catalogue to zero, stop and ask a person.
- Report back in plain words: what was added, changed and rejected, and why.
When an import feeds an online shop or ERP, the same thinking applies to keeping systems in step, which we cover in event-driven integration between warehouse and web shop. If the source is scanned paperwork rather than files, it becomes an OCR and document processing job.
Scheduling: cron, Timers or a Task Queue
How a job is triggered depends on how many jobs there are and how they relate to each other:
- cron or systemd timers on a server are fine for a handful of independent jobs. systemd timers add logging through the journal and can catch up on runs missed while the server was off.
- Celery with Celery beat, or a lighter library such as APScheduler, suits jobs that live inside a Django or FastAPI application and share its models and settings.
- Scheduled containers or serverless functions suit teams already on AWS, Azure or Google Cloud who would rather not maintain a server.
- A workflow tool such as Prefect or Airflow earns its place only when jobs depend on each other in chains and you need retries and history for each step.
Whatever triggers it, prevent overlapping runs with a lock, so a slow Monday job is never still running when Tuesday's starts.
Making Scripts Production Software
The difference between a helpful script and a liability is the unglamorous part:
- Version control and pinned dependencies, managed with a tool such as uv or pip-tools, so the job runs the same way next year.
- Configuration and secrets outside the code, in environment variables or a secrets store.
- Structured logs with enough detail to answer "what happened last Tuesday?"
- Alerts on failure, and on silence. A job that stops running produces no error. A heartbeat check that expects a signal after each successful run catches it.
- Tests with pytest for the calculation and validation logic, using small sample files that include the awkward cases.
- A short runbook: what the job does, who relies on it, and how to rerun it safely.
We run these jobs on your existing servers or in containers, and monitoring ties in with our maintenance and support plans so someone notices when a job fails. Where results need a permanent home, a properly designed schema from our database development work beats yet another spreadsheet.
Where to Start
List the routine tasks your team repeats each week, note roughly how long each takes and what goes wrong when it is late or missed. The best first candidate is frequent, rule-based and painful when it slips. If you would like a second opinion on that list, send it to us and we will tell you which jobs are worth automating first and what each one involves.
Frequently Asked Questions
Can Python automate tasks in software that has no API?
Often, yes. Many systems can export or import files on a schedule, or have a database that can be read safely. Where there is truly no other route, browser automation with Playwright can drive a web interface, though it is more fragile and needs closer monitoring. We always look for an API or file route first.
Where do automated jobs run if we have no servers of our own?
On a small cloud server, as scheduled containers or serverless functions on AWS, Azure or Google Cloud, or alongside an existing web application on its hosting. The right choice depends on how many jobs there are, what systems they need to reach, and whether they must sit inside your network.
What happens when a supplier changes the format of their file?
A well-built import notices before any damage is done. Validation checks the columns and values against a defined schema, rejects the file if they do not match, and alerts the right person with a clear message. Updating the mapping is then a small, tested change rather than a data clean-up.
Should we use Python or a no-code automation tool?
No-code tools such as Zapier or Make suit simple triggers between popular apps. Python is the better choice when the logic is involved, files are large, data needs validating and reconciling, or the job touches databases and internal systems. Many businesses use both, with Python handling the heavier jobs.
Can our own staff maintain the scripts afterwards?
Yes, if they are written for it. We keep each job small and readable, document what it does and who relies on it, include tests and sample files, and pin dependencies. Someone comfortable with spreadsheets and basic scripting can usually follow the logic; deeper changes may still need a developer.











