46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import argparse
|
|
import tempfile
|
|
import polars as pl
|
|
from pathlib import Path
|
|
|
|
from pipeline.utils import download
|
|
|
|
# Management information - state-funded schools - latest inspections (as at 28 Feb 2026)
|
|
# Source: https://www.gov.uk/government/statistical-data-sets/monthly-management-information-ofsteds-school-inspections-outcomes
|
|
URL = "https://assets.publishing.service.gov.uk/media/69c5269b4a06660f0854427b/Management_information_-_state-funded_schools_-_latest_inspections_as_at_28_Feb_2026.csv"
|
|
|
|
|
|
def convert_to_parquet(csv_path: Path, parquet_path: Path) -> None:
|
|
print("Reading CSV...")
|
|
|
|
df = pl.read_csv(
|
|
csv_path,
|
|
infer_schema_length=10000,
|
|
encoding="utf8-lossy",
|
|
null_values=["NULL", "Not applicable"],
|
|
)
|
|
|
|
print(f"Shape: {df.shape}")
|
|
print(f"Columns: {df.columns}")
|
|
|
|
df.write_parquet(parquet_path, compression="zstd")
|
|
print(f"Saved to {parquet_path}")
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(
|
|
description="Download Ofsted school inspection outcomes data"
|
|
)
|
|
parser.add_argument(
|
|
"--output", type=Path, required=True, help="Output parquet file path"
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
with tempfile.TemporaryDirectory() as cache_dir:
|
|
csv_path = Path(cache_dir) / "ofsted_latest_inspections.csv"
|
|
download(URL, csv_path, timeout=60)
|
|
convert_to_parquet(csv_path, args.output)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|