Improve speed reading in a .dat file
6 views (last 30 days)
Show older comments
Im attempting to process some rather heafty .dat files with 500k+ lines. The bulk of my code runtime is being taken up by two functions
fgetl and str2double
Does anyone know a faster way to read in a dat file or functions that run faster
2 Comments
Stephen23
on 4 Mar 2021
If at all possible, the fastest would be
but whether you can use it depends on the file format, which you have not told us anything about.
If you want further help with this, upload a representative** file by clicking the paperclip button.
** This means exactly the same file format, EOL characters, delimiter, number formats, etc., but small enough so that you can upload it on this forum. Probably you achieve this by keeping only the first few hundred lines.
Answers (2)
Image Analyst
on 4 Mar 2021
You could try fileread() to read in the whole file into one variable in one shot, then go through it parsing it.
0 Comments
See Also
Categories
Find more on Characters and Strings 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!