Extract column values and save in folder in form of .txt form. I need help in this...

2 views (last 30 days)
saeeda saher
saeeda saher on 6 Nov 2017
Commented: saeeda saher on 6 Nov 2017
I have csv file, it has three columns, emotion, pixels,usage. and i have folders 0,1,2,3,4,5,6,7 . i want to check firs column value row by row if the value is 0 then the second column pixel value in that row should save in form of txt file in 0 folder, if the value is 1 then save pixel value of that row in form of txt in 1 folder, if value is 2 then save in folder 2, if value is 3 then save in folder 3 and so on....
kindly help me , i am trying from last one week. but yet have not found any solution.
  2 Comments
saeeda saher
saeeda saher on 6 Nov 2017
i have just loaded the file only
for k=0:6
[status, msg, msgID] = mkdir( num2str(k )) ;
end
opt = {'Delimiter',',','Bufsize',pow2(14)};
[fid,msg] = fopen('data.csv','rt ');
assert(fid>=3,msg )
hdr = regexp(fgetl(fid),'\S+','match ');
C = textscan(fid,'%d%s%s',opt {:});
fclose(fid );
fun = @(s)sscanf(s,'%d ').';
C{2} = cell2mat(cellfun(fun,C{2},'uni',0));
Till here my work is done, now i want to save data in created folders. as mentioned in question.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!