[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Read file containing multiple data types

From: Saji Kuttan
Subject: Read file containing multiple data types
Date: Sat, 3 Nov 2018 15:38:43 +0530


I have a text file which is attached. The file has some header lines, that have to be skipped. I am trying to read the data in the file with different choices such as load, importdata, and fscanf. I think only fscanf can be used here. Even with fscanf, I have some problems.

I used fscanf as :

for i=1:33
[d,c1,c2,t]=fscanf(fid," %d %s %s %f", "C");
printf("%d %f\n", d,t)
x=fgetl(fid);  % to skip remaining part of the line

This code is not perfect because:

(1) I have to manually count the number of lines in the text file. I don't know to apply automatic EOF.
(2) There are some missing data, given as "..." at the end. Here the numeric field is changed to character. How it can be solved?

So please tell me how to read this file and save the data into different variables.

Saji P K
Assistant Professor
Department of Physical Oceanography
School of Marine Sciences,
Cochin University of Science and Technology,
Fine Arts Avenue
Kochi - 682016

Phone : (O) 0484 2863206 (Mob) 9744000804
Email : address@hidden
Web :

Attachment: t.txt
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]