How can I read a large Excel sheet with low runtime?
14 views (last 30 days)
Show older comments
I'm trying to read an Excel spreadsheet with ~500,000 rows and ~10 columns. I'm worried about the runtime of my script. I think it would be great if MATLAB could read the information in under a minute. However, two minutes would be in the range of acceptibility. Is this run speed possible to accomplish with the size of my spreadsheet? If so, how?
BTW, my idea is to skip every five rows of data when reading the Excel file, however I would rather not do this. Also, i'm unsure if it will solve the problem.
Thankyou
0 Comments
Answers (1)
Guillaume
on 4 Feb 2019
First, why is it such a worry? Are you reading that spreadsheet in a loop? If so, why? Does it change each time? If not, why does it matter if the initial import takes a bit longer?
Note that unless you're using the 'basic' mode of xlsread or 'UseExcel', false of readtable, then matlab has first to start Excel before it can even read the data from your file. As you probably know, Excel can take a while to start and that's totally out of the control of matlab. Once excel has started, it's excel that opens the file. Again, out of the control of matlab. Finally, once all that is done, matlab can ask excel for the content of the spreadsheet and to be honest whether you ask for the whole lot or just 1 in 5 row is not going to make much difference compared to the rest. It may be that actually skipping rows may take longer since you need to spend time computing which cells need copying rather than copying the whole lot in one go.
If you use 'basic' mode or equivalent, then you're relying solely on matlab to parse the file. It's not as powerful but it may be faster since you don't have to wait around for excel to do its thing.
But to be honest, I don't think it's something you should worry about until you've proven that it's actually a problem. Premature optimisation is wasted effort. So have you actually timed how long it takes to read your data?
0 Comments
See Also
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!