%[num, txt]=xlsread('Adultincome/adultdata.xls');
fp=fopen('Adultincome/adult.data.txt', 'r');
tline=fgetl(fp);
ndat=zeros(6, 32000);
ys=zeros(32000, 1);
ptr=1;
while ((ischar(tline))&&(ptr<32001))
    commas=strfind(tline, ',');
    nvs=zeros(6, 1);
    svs=cell(9, 1);
    nvs(1)=sscanf(tline(1:commas(1)-1), '%d');
    svs(1)={tline(commas(1)+1:commas(2)-1)};
    nvs(2)=sscanf(tline(commas(2)+1:commas(3)-1), '%d');
    svs(2)={tline(commas(3)+1:commas(4)-1)};
    nvs(3)=sscanf(tline(commas(4)+1:commas(5)-1), '%d');
    svs(3)={tline(commas(5)+1:commas(6)-1)};
    svs(4)={tline(commas(6)+1:commas(7)-1)};
    svs(5)={tline(commas(7)+1:commas(8)-1)};
    svs(6)={tline(commas(8)+1:commas(9)-1)};
    svs(7)={tline(commas(9)+1:commas(10)-1)};
    nvs(4)=sscanf(tline(commas(10)+1:commas(11)-1), '%d');
    nvs(5)=sscanf(tline(commas(11)+1:commas(12)-1), '%d');
    nvs(6)=sscanf(tline(commas(12)+1:commas(13)-1), '%d');
    svs(8)={tline(commas(13)+1:commas(14)-1)};
    svs(9)={tline(commas(14)+1:end)};
    ndat(:, ptr)=nvs;
    ys(ptr)=strcmp(svs(9), ' <=50K');
    tline=fgetl(fp);
    ptr=ptr+1;
    %wa=sscanf(tline, '%d,%s,%d,%s,%d,%s,%s,%s,%s,%s,%d,%d,%d,%s,%s');
end
fclose(fp)
