Problems for downloading the Track data #596
When we tried to load the track data by R, it shows the error of connection.
Code:
load_VDB <- function(file_url) {
con <- gzcon(url(file_url))
txt <- readLines(con)
return(read.csv(textConnection(txt)))
}
tid<-load_VDB("https://api.vitaldb.net/TID")
another trial: tid<-load_VDB("https://api.vitaldb.net/{tid}")
tid<-load_VDB("https://api.vitaldb.net/")
The error:
Error in readLines(con) :
cannot open the connection to 'https://api.vitaldb.net/TID';
In addition: Warning message:
In readLines(con) :
cannot open URL 'https://api.vitaldb.net/TID';: HTTP status was '403 Forbidden'
We also tried to load the cases by loops, the same error occurred.
Code:
load_case <- function(tname, caseid){
tracks <- load_VDB("https://api.vitaldb.net/trks.csv.gz")
tracks <- tracks[tracks$caseid == caseid,]
tid <- (tracks[tracks$tname == tname,])$tid
return(load_trk(tid))
}
ID<-as.data.frame(cases[,1])
colnames(ID)[1]="caseid"
tname<-as.data.frame(unique(trks$tname))
colnames(tname)[1]="tname"
dat_monitor<-data.frame()
i=1
for(i in 1:6388){
ID<-cases[i,1]
tname1<-tname[1,1]
a<-load_case(tname = tname1,ID)
a$caseid<-rep(ID,length(a[,1]))
dat_monitor<-rbind(dat_monitor,a)
i=i+1
}
Error:
Error in readLines(con) : cannot read from connection
In addition: Warning message:
In readLines(con) :
URL 'https://api.vitaldb.net/trks.csv.gz';: Timeout of 60 seconds was reached
Would you help us handle this problem? Thanks.
I think the semi-colon at the end of url could be the problem. I've tested the url, and it did work.
Also, could you elaborate what you mean by "load"?
Do you mean you want to download all track data to .csv file?
Downloading/storing all data to csv file is possible, but I don't think you can load 6388 case data to R's dataframe in one run.
Your PC memory might not be able to bear it.
Best regards,
VitalDB