Reputation: 15
I am working on a project with the data of magnitude of variable stars and I have come across a problem:
The data I have in a .txt document has a lot of comments marked with the symbol #
, I would like to know if there is a way to read the whole text and take just the lines that does not include this particular character, I have already read the whole text and put into an array:
fid=fopen('000006+2553.txt','r');
i=1;
while 1
tline=fgetl(fid);
if ~ischar(tline), break, end
A{i}=tline;
i=i+1;
end
but from there I don't know how to follow.
Upvotes: 0
Views: 467
Reputation: 4732
just add a
if tline(1)=='#', continue, end
to your loop. That's quite a standard snippet.
note I just check the first character on purpose, as I have come across data files that contain comments after data in the same line. Also (valid) string fields might include the character.
Upvotes: 1