Format python
This commit is contained in:
parent
85f5770e09
commit
4c258018c3
17 changed files with 348 additions and 248 deletions
|
|
@ -35,7 +35,6 @@ def download_with_progress(url: str, output_path: Path) -> None:
|
|||
return
|
||||
|
||||
|
||||
|
||||
def extract_zip(zip_path: Path, extract_path: Path) -> None:
|
||||
extract_path.mkdir(exist_ok=True)
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ def extract_zip(zip_path: Path, extract_path: Path) -> None:
|
|||
|
||||
|
||||
def convert_to_parquet(data_path: Path, parquet_path: Path) -> None:
|
||||
df = pl.scan_csv(data_path / 'Data/NSPL_MAY_2025_UK.csv', try_parse_dates=True)
|
||||
df = pl.scan_csv(data_path / "Data/NSPL_MAY_2025_UK.csv", try_parse_dates=True)
|
||||
print(f"Columns: {df.collect_schema().names()}")
|
||||
parquet_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
df.sink_parquet(parquet_path, compression="zstd")
|
||||
|
|
@ -52,8 +51,12 @@ def convert_to_parquet(data_path: Path, parquet_path: Path) -> None:
|
|||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="Download and convert ArcGIS postcode data")
|
||||
parser.add_argument("--output", type=Path, required=True, help="Output parquet file path")
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Download and convert ArcGIS postcode data"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--output", type=Path, required=True, help="Output parquet file path"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
with tempfile.TemporaryDirectory() as cache_dir:
|
||||
|
|
@ -64,5 +67,6 @@ def main() -> None:
|
|||
extract_zip(download_path, extract_path)
|
||||
convert_to_parquet(extract_path, args.output)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue