Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: problem in reading comma delimited data array
Date: Mon, 5 Jan 2009 00:55:02 +0000 (UTC)
Organization: The MathWorks Inc
Lines: 45
Message-ID: <gjrlp6$6jc$1@fred.mathworks.com>
References: <cfb037ff-f11b-4d59-b97d-261e9a0a84bc@n33g2000pri.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1231116902 6764 172.30.248.37 (5 Jan 2009 00:55:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 5 Jan 2009 00:55:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 869871
Xref: news.mathworks.com comp.soft-sys.matlab:509790


soms.sharma@gmail.com wrote in message <cfb037ff-f11b-4d59-b97d-261e9a0a84bc@n33g2000pri.googlegroups.com>...
> Hi,
> 
> I have to read comma delimited array data with nonuniform
> rows,columns. I just needed to read these data into single array A.
> I did like this:
> 
> A=dlmread(filename, ',' )
> 
> but this does not displays all data and introduces unwanted zeros.
> What I need is just in the form of continous array.
> A(1)=1157
> A(2)=1088
> ....
> 
> A(n)=957
> 
> Could you please suggest how to accomplish this task?
> 
> 1157,1088,1169,1169,984,1322,1178,1103,1211,1292,
> 1124,
> 1171,1133,
> 1227,1142,1216,1259,1299,1232,1117,1155,
> 1232,1083,1020,1394,1196,1148,1083,1189,1133,1034,
> 1157,1034,1097,1299,1157,1130,1155,1349,1232,1103,
> 1103,1083,1027,1166,1148,1250,1155,1047,1054,1018,
> 1189,1126,1250,1297,1178,1043,1103,1250,1272,1169,
> 1004,1083,1164,1124,1027,995,1169,1270,1011,1247,
> 1101,1004,1004,1065,1223,1184,1216,1180,1142,1277,
> 1206,1076,1076,1189,1121,1178,1031,1076,1178,1209,
> 1022,1220,1070,1126,1058,1216,1358,1184,1083,1097,
> 1119,1097,1097,1153,1153,1151,1151,1151,1184,1097,
> 1043,1043,1002,1152,1097,1034,1002,989,1092,1115,
> 1115,1047,1040,1038,1085,1126,1058,1067,1115,1263,
> 1124,1110,1097,1097,1157,1000,991,995,1013,1007,
> 971,971,980,993,1043,1097,982,971,971,1065,
> 1022,1029,989,1029,995,982,1090,980,971,957

You can use TEXTSCAN:

>> fid = fopen(filename);
>> d = textscan(fid, '%f', 'delimiter', ',');
>> d = d{1};