image thumbnail


version (2.06 KB) by Jacob
Quickly load offset data from ascii file


Updated 03 Sep 2013

View License

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.
%[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.

Cite As

Jacob (2022). load_ascii (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!