VariableNames = {'Date', 'Level', 'delim1', 'PID', 'delim2', 'Message'};
VariableWidths = [19, 5, 1, 23, 2, 5000];
VariableTypes = {'datetime', 'char', 'char', 'char', 'char', 'char'};
opts = fixedWidthImportOptions('VariableNames', VariableNames, 'VariableWidths', VariableWidths, 'VariableTypes', VariableTypes, 'SelectedVariableNames', [1, 2, 4, 6]);
opts = setvaropts(opts, 'Date', 'InputFormat', 'MM/yy hh:mm:ss.SSS');
content = readtable('test_that.txt', opts);
fid = fopen('test_that.txt', 'rt');
content = textscan(fid, '%18c%*c%5c%*c%23c%*2c%s', 'Delimiter', '', 'Whitespace', '');
fclose(fid);
content = [cellstr(content{1}), cellstr(content{2}), cellstr(content{3}), content{4}]
5 Comments
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/472084-how-to-parse-text-data#comment_725363
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/472084-how-to-parse-text-data#comment_725363
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/472084-how-to-parse-text-data#comment_725625
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/472084-how-to-parse-text-data#comment_725625
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/472084-how-to-parse-text-data#comment_726230
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/472084-how-to-parse-text-data#comment_726230
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/472084-how-to-parse-text-data#comment_726232
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/472084-how-to-parse-text-data#comment_726232
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/472084-how-to-parse-text-data#comment_727255
Direct link to this comment
https://au.mathworks.com/matlabcentral/answers/472084-how-to-parse-text-data#comment_727255
Sign in to comment.