diff --git a/layers/fcc/towers/process.py b/layers/fcc/towers/process.py index 479c789..a91ae57 100755 --- a/layers/fcc/towers/process.py +++ b/layers/fcc/towers/process.py @@ -5,6 +5,7 @@ import csv import io import json import zipfile +import urllib.request fieldnames = { "CO": ("Record Type", "Content Indicator", "File Number", "Registration Number", "Unique System Identifier", @@ -15,8 +16,8 @@ fieldnames = { } filenames = ["CO", "EN", "HS", "RA", "RE", "SC"] files = {} - -with zipfile.ZipFile("r_tower.zip", "r") as z: +resp = urllib.request.urlopen("https://data.fcc.gov/download/pub/uls/complete/r_tower.zip") +with zipfile.ZipFile(io.BytesIO(resp.read())) as z: for filename in filenames: with z.open(f"{filename}.dat", "r") as f, io.TextIOWrapper( # Avoids `_csv.Error: iterator should return strings, not bytes (the file should be opened in text mode)` f, encoding="utf-8", newline="", errors="replace"