---
name: uk-dft-port-freight-statistics-ingestion
description: "How to get UK DfT port freight statistics data into a pandas DataFrame and Parquet: access, the request, the format, limits, quirks and terms."
---

# Load UK DfT quarterly port tonnage (PORT0502) into pandas and Parquet

Source entry: https://signal-lab-jet.vercel.app/datasets/uk-dft-port-freight-statistics
Provider: https://www.gov.uk/government/statistical-data-sets/port-and-domestic-waterborne-freight-statistics-port
Checked against the provider's documentation: 2026-11-05

## Access
- No account or key. ODS tables download directly over HTTPS from assets.publishing.service.gov.uk.

## Request
```bash
curl -s -o port0502.ods 'https://assets.publishing.service.gov.uk/media/6a96f36001bbff0bf8f97c3e/port0502.ods'
```

## Format
ODS workbook with one sheet per tonnage/units direction (e.g. Tonnage_(Both_Directions)); each sheet has note rows above a header row ("Major Port", then one column per quarter from 2009 Q1), ending with a "Total at all major ports" row.

## Load into pandas and Parquet
Needs Python 3 with requests, pandas and pyarrow.
```python
"""UK DfT PORT0502 quarterly tonnage -> pandas. No key.

Downloads the ODS table directly and reads the tonnage-by-direction sheet; needs the odfpy
engine for pandas to read .ods files.
"""
import requests
import pandas as pd

URL = "https://assets.publishing.service.gov.uk/media/6a96f36001bbff0bf8f97c3e/port0502.ods"
r = requests.get(URL, timeout=60)
r.raise_for_status()
with open("port0502.ods", "wb") as f:
    f.write(r.content)
df = pd.read_excel("port0502.ods", engine="odf", sheet_name="Tonnage_(Both_Directions)", header=6)
df = df.dropna(subset=["Major Port"])
latest_col = [c for c in df.columns if str(c).startswith("2026")][-1]
df.to_parquet("uk_dft_port0502.parquet", index=False)
print(len(df), "port rows; latest column:", latest_col, "-", df.iloc[0]["Major Port"], df.iloc[0][latest_col])
```
Run by us on 2026-11-05 (python 3.13.5 | pandas 3.0.6 | odfpy 1.4.1 | requests 2.34.2). Result: 54 port rows (53 major ports plus a Total at all major ports row); latest column: 2026 Q2 [Note 5] - Aberdeen 815.356 (thousand tonnes).

## Limits
- Rate limits: Not stated.
- The 2026 Q1 and Q2 columns are marked [Note 5] (provisional/early figures) in the workbook's own notes.

## Quirks
- The shortlisted port-freight-monthly-datasets URL returns a 404; use this statistical-data-sets page instead.
- Files are ODS, not CSV or XLSX; pandas needs the odfpy engine, and each workbook has several title/note rows before the real header row.

## Terms and attribution
- UK DfT port freight tables are published under the Open Government Licence v3.0: "Contains public sector information licensed under the Open Government Licence v3.0."
- Terms page: https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/

## Sources
- https://www.gov.uk/government/statistical-data-sets/port-and-domestic-waterborne-freight-statistics-port: "UK major port traffic, total tonnage and units, by port: quarterly from 2009"
- https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/: "Contains public sector information licensed under the Open Government Licence v3.0."

## Help improve this skill
Missing a source, or see something to improve? Call the MCP tool suggest_source or feedback (or POST /api/suggest or /api/feedback). Reviewed ideas: https://signal-lab-jet.vercel.app/agent-suggestions

Information for educational purposes only. Free tiers, limits and licenses belong to the providers and may change; check the provider's own terms before using the data.
