Skip to content

Commit b377046

Browse files
committed
Fixes histrical script so that it adds to existing data instead of overwriting it
1 parent 4344352 commit b377046

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

code/get_historical_data.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,11 +177,17 @@ lapply(seq(1, length(these_dates), chunksize), function(j){
177177

178178
}))
179179

180-
if(!is.null(stored_weather_daily)){
181-
weather_daily = rbindlist(list(weather_daily, stored_weather_daily))
182-
}
180+
print(paste0("Just grabbed ", nrow(weather_daily), " new records"))
181+
182+
if(file.exists("data/output/daily_station_historical.csv.gz")){
183+
stored_weather_daily = fread("data/output/daily_station_historical.csv.gz")
184+
185+
print(paste0("We already had ", nrow(stored_weather_daily), " records stored"))
186+
187+
weather_daily = rbindlist(list(weather_daily, stored_weather_daily))
188+
}
183189

184-
print("writing chunk")
190+
print(paste0("writing chunk with ", nrow(weather_daily), " records"))
185191

186192
fwrite(weather_daily, "data/output/daily_station_historical.csv.gz")
187193

0 commit comments

Comments
 (0)