How can i read text file?

i want to read text file but i want to start from 5 row to 230. In Addition i want to read Parameters till semicolon. Do you have any opinion?

3 Comments

What can you say about your text file? It appears to have a number of header rows, and a number of columns that are delimited by semi colons. try using importdata to read in the data. Use the option to ignore the first four rows and the delimiter option to indicate that each column is separated by a semi-colon.
Thanx how can i read then definite rows for example from 5:230
i applied what you told me but it reads after semi colons too. And i dont want to read first 4 columns and last 50 columns.
daten=fopen('msa02_141121_mscc5_11.erg','r')
zeile = textscan(daten,'%s','delimiter','\n')
fclose(daten);

Sign in to comment.

 Accepted Answer

dpb
dpb on 26 Jan 2015
Edited: dpb on 26 Jan 2015
Read
doc textscan
and the examples, carefully. There are sufficient examples and info there...
You seem to have mixed 'column' and 'row' in your description of what you want/don't want; I'll presume it's only the 5:230 rows to read(*) and all the columns...
fmt=['%s %s' repmat('%f',1,3)];
fid=fopen('msa02_141121_mscc5_11.erg','r');
zeile = textscan(fid,fmt,226,'delimiter',';','headerlines',4,'collectoutput',1);
fid=fclose(fid);
(*) Altho I used the option COUNT value above, unless the file is extremely large it's often faster to simply read the whole file and then just delete the portions of the data that are not of interest. This is so because for the whole file the i/o system can make maximum use of buffering and all as opposed to having to count records and return only that subsection required so may be sufficient overhead saved in the i/o processing to make up for the added amount data.

More Answers (0)

Asked:

on 26 Jan 2015

Edited:

dpb
on 26 Jan 2015

Community Treasure Hunt

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

Start Hunting!