Skip to content

Instantly share code, notes, and snippets.

@paleolimbot
Created October 2, 2019 15:28
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 paleolimbot/7ec21e034fb427085bba0c4522109d3c to your computer and use it in GitHub Desktop.
Save paleolimbot/7ec21e034fb427085bba0c4522109d3c to your computer and use it in GitHub Desktop.
library(tidyverse)
files <- crossing(
tibble(station_id = 42583, timeframe = 1),
tibble(year = 2018:2019),
tibble(month = 1:12)
) %>%
mutate(
url = glue::glue(
"http://climate.weather.gc.ca/climate_data/bulk_data_e.html?format=csv&Month={month}&stationID={station_id}&submit=Download%20Data&timeframe=1&Year={year}"
),
file = glue::glue("{station_id}_{timeframe}_{year}_{month}.csv")
)
walk2(files$url, files$file, curl::curl_download)
map_dfr(files$file, read_csv, col_types = cols(.default = col_character()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment