large date/number/string text file reading to certain number of elements then ignoring end of line

I have a problem reading in a text file.
It's a large txt file with each line (after the header) composed of time,date,799 x data integers seperated by a ', '
Tha would be fine and I'd be able to read the 2000 plus lines in with no problem sequentially, except every now and then a line is finished with a string starting 'Event: ...'
This messes up the time & date capture for the next line..
How can I tell the code to stop after the 799 integers, ignore the rest of the line and move to the next?
thanks

4 commentaires

Can you provide some sample data?
no sorry, I can't do that.
it's in the format:
[hh:mm:ss.ms, dd/mm/yy, 1, 2, ... n-1, n] with the occasional [hh:mm:ss.ms, dd/mm/yy, 1, 2, ... n-1, n, Event: N1.1]
Which version of MATLAB do you have?

Connectez-vous pour commenter.

 Réponse acceptée

To skip ret of the line use '%*[^\n]':
fid = fopen('test.txt');
fmt = ['%s%s' repmat('%f',1,10), '%*[^\n]'];
out = textscan(fid, fmt, 'Delimiter',',', 'CollectOutput',1);
fclose(fid);

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Export dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by