I'm trying to read the following file in R
It works when I paste the url directly in a browser but for some reason when its downloaded via R it cannot be opened.
I have tried download.file() with all its accepted methods ('lib-curl/internal/wininet/...')
u <- 'https://www.ssga.com/us/en/individual/etfs/library-content/products/fund-data/etfs/us/holdings-daily-us-en-xop.xlsx'
download.file(u)
The downloaded file cannot be opened manually nor in R via readxl::read_xlsx() nor gdata::read.xls()
I have also tried the httr package but it seems that content type 'xlsx:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' is not supported. I did learn however that the file seems to be gzipped but im not even sure if thats the problem
response <- httr:Get(u)
response$headers$`content-encoding`
"gzip"
Can someone suggest how I might be able to download this data within R?