minor edit ot get statsion data

This commit is contained in:
Simon 2024-08-16 12:39:36 +02:00
parent 12cebe247a
commit e227f2b172

View file

@ -23,13 +23,15 @@ getStationData <- function(start_date, end_date, station_id,headers = headers,dp
response <- GET(url_with_params, headers) response <- GET(url_with_params, headers)
while(response$status_code == 204){ while(response$status_code == 204){
response <- GET(url_with_params, headers) response <- GET(url_with_params, headers)
print("file not finisehed") print("file not finished yet, wait 5s")
Sys.sleep(5) Sys.sleep(5)
} }
if(response$status_code == 201){ if(response$status_code == 201){
return(read.csv(text=content(response,as="text")[[1]],sep=";",header=T,dec = ",")) return(read.csv(text=content(response,as="text")[[1]],sep=";",header=T,dec = ","))
} }
} }
stop(sprintf("Failed to retrieve data from the API. Status code: %s", response$status_code)) print(sprintf("Failed to retrieve data from the API. Status code: %s", response$status_code))
return(NULL)
} }