|
In article <gpego5$n8k$1@fred.mathworks.com>,
"Pete sherer" <tsh@abg.com> wrote:
> I have a text file that each data contains 2 rows of information
> 900,id,name,age,height,sex
> 901,weight,occupation
>
> Example:
>
> 900,1,Jim,60,175,male
> 901,150,none
> 900,2,Paul,30,190,male
> 901,233,engineer
>
> With this non-uniform data, can I use TEXTSCAN to read the data above?
Yes, with something like this:
>> fid = fopen('pete.dat');
>> c = textscan(fid,'%*n%n%s%n%n%s%*n%n%s',...
'Delimiter',',\n','Whitespace','');
>> fclose(fid);
>> c{1}
ans =
1
2
>> c{2}
ans =
'Jim'
'Paul'
>> c{3}
ans =
60
30
>> c{4}
ans =
175
190
>> c{5}
ans =
'male'
'male'
>> c{6}
ans =
150
233
>> c{7}
ans =
'none'
'engineer'
--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
|