Home > Software engineering >  How can I download .ods data from web to R?
How can I download .ods data from web to R?

Time:10-06

I would like to ask how I could download an .ods dataset from web (specifically this site: https://knowledge4policy.ec.europa.eu/territorial/ardeco-online_en?fbclid=IwAR1CPVLzdey8MnMZDLA-9NpvMDAJqMq1WHmm6yu8FtRAk01u9K184wCU7Wc) directly to R? I tried the following read_ODS code

a <- read_ods(path = url("https://knowledge4policy.ec.europa.eu/sites/default/files/RNPTD.ods"), sheet = 1)

and got the error "Error in file.exists(file) : invalid 'file' argument" Did I make a mistake here or does read_ods load only local files?

CodePudding user response:

This seems to work fine:

url1 <- "https://knowledge4policy.ec.europa.eu/sites/default/files/RNPTD.ods"
f <- tempfile()
download.file(url1, dest=f)
x <- readODS::read_ods(f)
unlink(f)

That is, you can't read directly from an ODS file located at a URL (or at least, it didn't work for me), but downloading to a temp file and reading works.

  •  Tags:  
  • r ods
  • Related