Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
  1. Home
  2. Blog
  3. Moving and Transforming Data Reliably
Python & Django

Moving and Transforming Data Reliably

Building data pipelines in Python that cope with malformed input: restartable stages, quarantining failures, reconciling counts and alerting on absence.

Updated 2 min readBy SpiderHunts Technologies

Free estimateNo obligation

Get a free estimate

Tell us what you need. A senior engineer reads every enquiry.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →

Quick answer — TL;DR

Assume the input will be malformed, make every stage restartable, quarantine what fails rather than stopping, and reconcile counts at the end of every run.

The input will be wrong

Pipelines fail in production because real data contains things the sample did not: missing fields, unexpected encodings, dates in a different format, and records that break an assumption nobody wrote down.

A pipeline that stops on the first bad record will stop most nights. One that quarantines bad records and processes the rest keeps working while you investigate.

Design principles

  1. Validate on entry and quarantine what fails, with the reason
  2. Make each stage restartable from its input rather than from the beginning
  3. Store intermediate output, so a later failure does not require redoing earlier work
  4. Be idempotent — rerunning must not duplicate
  5. Reconcile — count in, count out, count quarantined

Reconciliation is the safety net

Every run should report how many records entered, how many completed, how many were quarantined and how many were rejected. Those numbers should add up.

  • An unexplained gap means silent data loss
  • A quarantine count that jumps means the input changed
  • A completed count of zero means something upstream broke
  • All three should alert

Handle the awkward realities

RealityHandling
Encodings varyDetect and normalise on entry
Dates in several formatsParse explicitly, reject ambiguity
Duplicate source recordsDeduplicate on a defined key
Late-arriving dataDesign for reprocessing a period
Source unavailableRetry, then alert — do not silently skip

Alert on absence, not just errors

A pipeline that processes nothing looks identical to a pipeline with nothing to process. Only a completion signal with an expected volume distinguishes them.

That is the alert that catches the failures which otherwise run for weeks.

FAQ

Frequently asked questions

The questions readers ask us after this guide.

Still have a question?

Ask us directly — a senior engineer will get back to you.

Ask about your project

Do we need a pipeline framework?

For a handful of jobs, plain Python with a scheduler is simpler. Frameworks earn their place with complex dependencies between many jobs.

What about very large volumes?

Batch and stream in chunks rather than loading everything into memory. That single practice handles most volume problems.

How do we test a pipeline?

With real sample data including the awkward records, and with deliberately malformed input. Testing only clean data tests the wrong thing.

What if the source format changes?

Validation catches it and quarantines the records. That is far better than processing them wrongly and discovering it later.

Keep reading

More on Python & Django

Python & Django

An API Other Systems Can Depend On

Designing a Python API service others can depend on: validation at the boundary, consistent errors and status codes, early versioning and documentation.

Python & Django

Scraping That Keeps Working

Web scraping with Python that keeps working: checking terms and robots files, rate limiting, coping with structure changes and spotting silent failure.

Start here

Pipeline that fails silently overnight?

Reconciliation and absence alerting fix that. Happy to look at how yours reports.

  1. You tell us what you needTwo minutes on the form, or a message on WhatsApp.
  2. A senior engineer reviews itAnd comes back with questions, a realistic range and an honest view on fit.
  3. Free 30-minute scoping callWe talk through scope, options and a realistic estimate — with no obligation.
Free estimateNo obligation

Talk to someone who builds this

Send a short brief and we will come back with an honest view and a realistic range.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →