필터 지우기
필터 지우기

to read multiple csv files

조회 수: 1 (최근 30일)
sarfudeen
sarfudeen 2014년 10월 15일
답변: Ken Atwell 2014년 10월 15일
I used the following code for reading the multiple csv files but for the execution it takes too much of time.
My code is as follows:
[files,path] = uigetfile('*.csv', 'MultiSelect','on');
FileName = fullfile(path,file);
fmt = '%s%s%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%';
num = length(FileName);
data = cell(1,num);
for i = 1 : num
fid = fopen(FileName{i},'r');
data(i) = textscan(fid,fmt,'Delimiter',',',CollectOutput',1);
end
Hence sort out this and help me in this bug at the earliest...
Regards, M. Sarfudeen

답변 (1개)

Ken Atwell
Ken Atwell 2014년 10월 15일
How many files are we talking about, and how big is each file?
If you have R2014b, you may want to check out the new datastore capability as a more elegant approach to what you're doing. It may not help with your performance issue, though.
PS: Don't forget to fclose your files, especially if you have lots of them.

카테고리

Help CenterFile 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!

Translated by