reading and splitting csv file
이전 댓글 표시
Hi,
I'm having troubles with a big csv file (attached).
If I try to read it as a table with readtable, MatLab displays the error: "All lines of a text file must have the same number of delimiters".
I made a check for delimiters with medhan ravi code from https://it.mathworks.com/matlabcentral/answers/418855-how-do-i-ensure-that-the-number-of-delimiters-on-each-row-are-constant-when-reading-a-hige-csv-file and apparently all the records have the same number of delimiters...
I would like to split the file in 4 tables, that I can use for elaborating datas. as you can see, each table in the source file starts with character 'I', while the other rows starts with 'D'.
I have tried with this (implementing medhan ravi code):
fid=fopen('PUBLIC_PRICES_201911180000_20191119040539.CSV ','r'); % open the file
l=fgetl(fid); % read first line
i=1; % record counter
while ~feof(fid) % rest of file
l=fgetl(fid);
if ~startsWith(l,'I')
table{i}={table{i};l};
else
i=i+1;
table{i}={l}
end
end
I tried to concatenate rows with curly brackets but didn't work.
I would really appreciate any help,
thanks you all
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!