best way to import this csv
조회 수: 1 (최근 30일)
이전 댓글 표시
I can't work out how to import this csv file - https://dl.dropbox.com/u/11341635/Data.csv
Have tried various methods but I find a lot of the functions and terms are brand new to me so a lot of the forum posts and help files I'm reading are just over my head.
댓글 수: 2
Walter Roberson
2012년 12월 14일
Which fields of it do you need?
You will not be able to use csvread() as that is only suitable for files that are completely numeric.
채택된 답변
Walter Roberson
2012년 12월 15일
fid = fopen('Data.csv', 'rt');
fmt = ['%f', '%f', repmat('%f', 1, 20), repmat('%f', 1, 20), repmat('%s', 1, 20)];
dat = textscan(fid, fmt, 'HeaderLines', 1, 'Delimiter', ',');
fclose(fid);
ID = dat{1};
Hl = dat{2};
C = cell2mat(dat(3:22));
AB = cell2mat(dat(23:42));
spkrs = [dat{43:62}];
Now ID, H1, C, and AB are numeric arrays, with the C(:,1) corresponding to C1, C(:,2) corresponding to C2, and so on. And spkrs is now a cell array of strings with spkrs{J,1} corresponding to row J of columns spkrs1, and so on.
댓글 수: 0
추가 답변 (1개)
per isakson
2012년 12월 15일
This file may be imported with textscan, however, it requires a correct format string, i.e. one need get the number of column correct.
There are some tools in the file exchange, which might read the file. I would have tried "readtext" by Peder Axensten first.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Large Files and Big Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!