Reading varying headerlines length, text files
Show older comments
Hi, I am trying to read specific part of the header lines for these files and once I read lines i want to increment for each block and display them into GUI edit text boxes.
fid= fopen([FilesToRead, MultipleFiles]);
textForGUI = cell(1);
while true
tLine = fgetl(fid);
headerCells = strsplit(tLine,' ');
if length(headerCells) > 1
if ~isempty(headerCells{2})
if ~strcmpi(headerCells{2},'!User') && ~strcmpi(headerCells{2},'data')
textForGUI(end+1) = headerCells(2);
else
break
end
end
end
end
textForGUI = textForGUI(2:end);
Block=0;
while true
tLine = fgetl(fid);
if ~ischar(tLine)
break;
end
if ~isempty(strfind(tLine,'data'))
Block=Block+1;
if true
% code
end
formatSpec = '%f %f %f %f %f';
C = textscan(fid,formatSpec,24,'CommentStyle','data','Delimiter','\t');
%here I got some calculations and plots
end
end
Thanks!
1 Comment
Matlab User
on 23 Aug 2016
Edited: Matlab User
on 29 Aug 2016
Accepted Answer
More Answers (0)
Categories
Find more on Sources in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!