File Exchange

image thumbnail


version 1.2 (2.06 KB) by

Quickly load offset data from ascii file



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.

Comments and Ratings (1)



updated comments in code. made description more accurate.


Fixed typo in description.

MATLAB Release
MATLAB 7.13 (R2011b)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video