Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Problem reading xlsx file downloaded by R

$
0
0

I'm trying to read the following file in R

https://www.ssga.com/us/en/individual/etfs/library-content/products/fund-data/etfs/us/holdings-daily-us-en-xop.xlsx

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?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>