Skip to content

Instantly share code, notes, and snippets.

@dyerrington
Created May 24, 2020 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dyerrington/f7819c88b9e902a242437669f345021b to your computer and use it in GitHub Desktop.
Save dyerrington/f7819c88b9e902a242437669f345021b to your computer and use it in GitHub Desktop.
import requests, re
def test_station_data_availability(station_id):
for year in range(1960, 2020 + 1):
r = requests.get(f"https://www.ncei.noaa.gov/data/local-climatological-data/access/{year}/")
matches = re.search(r"href=\"([0-9]{6}" +str(station_id) + ".csv)", r.text)
if matches:
print(station_id, " data exists for ", year)
else:
print(station_id, " data not found for ", year)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment