Downloading and saving Excel files using Matlab
Mostrar comentarios más antiguos
I would like to download this file: https://www.nbp.pl/en/statystyka/m3/podaz_bilansowa_en.xlsx and save it in the folder, all using Matlab. Is there any way I can do this? I red about 'urlread' and 'urlwrite' however do not know how exactly use it for my purpose.
5 comentarios
Mathieu NOE
el 18 de Mayo de 2021
hello
so why not dowload directly ?
Rik
el 18 de Mayo de 2021
What release are you using? And what have you tried? urlwrite has two inputs: URL and filename. What is your issue?
Joanna Przeworska
el 18 de Mayo de 2021
Rik
el 18 de Mayo de 2021
And what if you try websave?
websave(filename,fullURL);
Joanna Przeworska
el 18 de Mayo de 2021
Respuestas (1)
Rik
el 18 de Mayo de 2021
It seems this website blocks requests when it detects non-human requests.
You might be able to circumvent this by use the Wayback Machine. I have found that on some occasions that will work.
If you want an easy way to interact with the Wayback Machine from Matlab, you can get my WBM function from the FEX.
WBM(filename,fullURL);
14 comentarios
Joanna Przeworska
el 18 de Mayo de 2021
Rik
el 18 de Mayo de 2021
It should download the file to whereever you told it. What is the content of filename?
Joanna Przeworska
el 18 de Mayo de 2021
Rik
el 18 de Mayo de 2021
The name fullURL promises a full URL to the file. It doesn't fulfill that promise. The actual full URL is the concatenation of the two.
Try this:
filename = 'podaz_bilansowa_en.xlsx';
fullURL = ['https://www.nbp.pl/en/statystyka/m3/' filename];
out = WBM(filename,fullURL);
If that fails: I have an update almost ready, so I could attach it here for you.
Joanna Przeworska
el 18 de Mayo de 2021
Joanna Przeworska
el 19 de Mayo de 2021
Joanna Przeworska
el 19 de Mayo de 2021
Joanna Przeworska
el 19 de Mayo de 2021
That line should never trigger a warning, as it will only attempt deletion if the file exists, so your warning is very odd. It is also a bit strange that you're getting 403 errors.
filename = 'podaz_bilansowa_en.xlsx';
fullURL = ['https://www.nbp.pl/en/statystyka/m3/' filename];
out = WBM(filename,fullURL)
As you can see, this should work as expected. You should get a warning about a missing capture date, but the warning you're getting should never happen at all. This should not be different for R2019b.
Joanna Przeworska
el 19 de Mayo de 2021
Rik
el 19 de Mayo de 2021
If your IT department policy even disables reaching out to archive.org, you should ask them for suggestions.
If you have such a strict environment, why do you want to dynamically load a file from the internet anyway?
Joanna Przeworska
el 20 de Mayo de 2021
Categorías
Más información sobre Downloads en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
