Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Csvread

Subject: Csvread

From: Kris zenitis

Date: 16 Dec, 2010 00:21:11

Message: 1 of 7

Hello there. I ve got a data file that every line is like this:
921092, B, 7.729, 25.49, 47.98, 178.8 ,0.08098

I ve tried to read it with the csvread. So I use something like
csvread('text.txt') but i have problems due to the string that i have in the second column. Which function should i use to read lines like the above?

Subject: Csvread

From: Sadik

Date: 16 Dec, 2010 02:02:04

Message: 2 of 7

You could give textscan a try.

Subject: Csvread

From: ImageAnalyst

Date: 16 Dec, 2010 02:18:39

Message: 3 of 7

On Dec 15, 9:02 pm, "Sadik " <sadik.h...@gmail.com> wrote:
> You could give textscan a try.
-------------------------------------------------------------------
Or parse it yourself with fgetl() and sscanf().

Subject: Csvread

From: Oleg Komarov

Date: 16 Dec, 2010 03:16:05

Message: 4 of 7

"Kris zenitis" <gio.1988@hotmai.com> wrote in message <iebm1n$k9n$1@fred.mathworks.com>...
> Hello there. I ve got a data file that every line is like this:
> 921092, B, 7.729, 25.49, 47.98, 178.8 ,0.08098
>
> I ve tried to read it with the csvread. So I use something like
> csvread('text.txt') but i have problems due to the string that i have in the second column. Which function should i use to read lines like the above?

fid = fopen('fullpath to the txt file');
A = textscan(fid, '%f %s %f %f %f %f %f', 'Delimiter',',')
fid = fclose(fid);

Oleg

Subject: Csvread

From: Kris zenitis

Date: 18 Dec, 2010 12:28:05

Message: 5 of 7

Thanks very much oleg. I open the file in cell format. How can i use afterthat these cells?

Subject: Csvread

From: Snake

Date: 18 Dec, 2010 15:22:05

Message: 6 of 7

If i have in the second column just an integer(where i have the string). I can use textread. I manage to read the first row. But i must define how many rows i have and where to change line and read the new line. When I put '/n' as the last parameter before the number of rows is show me 'unknown option'.

Subject: Csvread

From: Snake

Date: 18 Dec, 2010 15:34:06

Message: 7 of 7

For example i have this code:
[a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32] = textread('demo.txt', '%5d %d %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f','/n',569)

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us