Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_excel unable to open file if the file is .xls but it was saved as .xml #727

Open
Despertaferro opened this issue Mar 29, 2023 · 1 comment

Comments

@Despertaferro
Copy link

I download the file:

https://www.blackrock.com/lu/intermediaries/products/253743/ishares-sp-500-b-ucits-etf-acc-fund/1538022822830.ajax?fileType=xls&fileName=iShares-Core-SP-500-UCITS-ETF-USD-Acc_fund&dataType=fund

using httr's GET.

But when I try to read this file, using:

myasset <- "iShares-Core-SP-500-UCITS-ETF-USD-Acc_fund"
read_excel(paste(my_wd, myasset, ".xls", sep=""), sheet = "Holdings")

I get the error message:

Error:
filepath: [mywd]\iShares-Core-SP-500-UCITS-ETF-USD-Acc_fund.xls
libxls error: Unable to open file

When I manually open the file, and I go to "Save as", I see that even though the file is saved as "*.xls", the extension is ".xml". I have checked with Blackrock, the provider, and also they see ".xml".

Instead, if I manually save the file as "*.xls", then I can open the file with read_excel.

Since I have many of these files, it is cumbersome to open the files manually, and to save them as ".xls" instead of the original ".xml".

Is there an R way to do that automatically?

@Despertaferro
Copy link
Author

If it is useful to answer my question, I can see the following:

file.exists(paste([mywd],, myasset, ".xls", sep=""))
[1] TRUE
format_from_ext(paste([mywd], myasset, ".xls", sep=""))
[1] "xls"
format_from_signature(paste([mywd],, myasset, ".xls", sep=""))
[1] NA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant