Error-tolerant parsing of newline-delimited data

버전 1.0.0.0 (49.7 KB) 작성자: Kevin Bartlett
Adaptive parsing of newline-separated data. Handles bad lines WITHOUT reading line-by-line.
다운로드 수: 332
업데이트 날짜: 2012/4/2

라이선스 보기

Generally, when parsing newline-delimited data, it is fastest to parse
all the lines in a single step, using "vectorized" functions like fscanf, rather than looping over the data line-by-line.

A single corrupt line in your data, however, can cause your parsing
function to fail. When this happens, the easiest workaround is to resort
to line-by-line parsing, but this can be extremely slow.

adaptive_parse.m provides a means to apply efficient parsing functions
to newline-delimited data containing corrupt lines. The user supplies
a parsing function, customised for his/her specific data file format,
which is passed to adaptive_parse as a function handle. If no corrupt
data lines are encountered, adaptive_parse calls the parsing function only once, returning the parsed data.

If the parsing function throws an error due to encountering a corrupt line, adaptive parse "rewinds" back to its prior position in the data and retries the parsing with half the number of lines. This is done iteratively until the bad line is read in singly and rejected. After this happens, adaptive_parse resumes parsing, rapidly ramping up the number of lines being parsed for greater speed.

Parsing a large number of lines at a time speeds up execution, but may
also result in Matlab exceeding its memory capacity. The user can specify a maximum number of lines to be parsed at a time to avoid this, or s/he can allow adaptive_parse to handle out-of-memory errors automatically. adaptive_parse.m responds to an out-of-memory error in
a similar way as it does to corrupt data lines: it iteratively halves
the number of lines being parsed until the error no longer occurs (a caveat: this mechanism works under Linux, but in Windows XP, Matlab seems to be unable to recover from the out-of-memory condition, and it freezes up).

The behaviour and efficiency of adaptive_parse.m can be modified through the use of optional initialisation, appender and cleanup functions, also provided by the user. Demonstration functions of these types have been included with this distribution of adaptive_parse.m, along with a demonstration parsing function and file of data that has been deliberately been corrupted to illustrate adaptive_parse's functionality.

인용 양식

Kevin Bartlett (2025). Error-tolerant parsing of newline-delimited data (https://kr.mathworks.com/matlabcentral/fileexchange/35932-error-tolerant-parsing-of-newline-delimited-data), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2011a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0