This function loads data from a tab delimited or csv ascii file similar to dlmread/importdata. If the file has fixed width columns and an offset is desired, it uses this information to quickly scan to desired area (making it significantly faster in those scenarios). Useful when working with very large ascii files that cannot be entirely loaded into memory at one time. If a file is loaded in with no offset, load_ascii is comparable to dlmread (faster/slower depends on delimiter). Importdata is many times slower than both.
Example usage:
Consider scenario where we have a very large ascii file (fixed width tab delimited, 24 header lines). We are only interested in a section of 2e6 lines, 20e6 past the end of the header.
%syntax
%[data,headerText] = load_ascii(filename,delimiter,header,nlines,offset)
tic;data = load_ascii(filename,'\t',24,2e6,20e6);toc;
tic;data2 = dlmread(filename,'\t',[20e6+24 0 12e6+23 2]);toc;
Elapsed time is 3.838641 seconds.
Elapsed time is 21.537717 seconds.
引用格式
Jacob (2024). load_ascii (https://www.mathworks.com/matlabcentral/fileexchange/40189-load_ascii), MATLAB Central File Exchange. 检索来源 .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!