Code covered by the BSD License  

Highlights from
Error-tolerant parsing of newline-delimited data

Error-tolerant parsing of newline-delimited data



Adaptive parsing of newline-separated data. Handles bad lines WITHOUT reading line-by-line.

function [parsed] = adaptive_parse_cleanup_demo(parsed,parsedPtrs,cleanupOptions)
% adaptive_parse_cleanup_demo.m--Cleanup function for demonstrating use of
% adaptive_parse().
% The "cleanupOptions" input argument is not used in this demo function,
% but it MUST appear in the function declaration.
% Syntax: parsed = adaptive_parse_cleanup_demo(parsed,parsedPtrs,cleanupOptions)

% Developed in Matlab (R2010b) on GLNX86.
% Kevin Bartlett (, 2011-03-23 10:14

% Crop the variables to their actual length (may have been
% over-initalised).
fieldNames = fieldnames(parsed);

for iField = 1:length(fieldNames)
    thisFieldName = fieldNames{iField};
    thisFieldEndPtr = parsedPtrs.(thisFieldName);
    parsed.(thisFieldName) = parsed.(thisFieldName)(1:thisFieldEndPtr);
end % for

Contact us