Read multiple csv files from a folder and not all csv files
조회 수: 1 (최근 30일)
이전 댓글 표시
I want to read multiple csv files from a folder and not all csv files.I have the names of the particular csv files in notepad format and i want to import those particular
files in matlab by reading that notepad files.
Eg loads.csv
loads1.csv
loads2.csv
loads3.csv
Suppose i want to read only loads.csv and loads2.csv from a folder
Currently am copying and pasting and creating a new folder and using function
f=dir(fullfile('D:\Matlab,'*.csv'));
But if i want to reduce the time and directly read the names from the notepad and go and search for those particular files in that folder so how to do it?
댓글 수: 0
답변 (1개)
KSSV
2019년 1월 10일
편집: KSSV
2019년 1월 10일
fid = fopen('myfile.txt','rt') ; % open your text pad file
S = textscan(fid,'%s','delimiter','\n') ;
S = S{1} ; % this has file names which are in notepad file
fclose(fid) ; % close the file
N = length(S) ; % toal number of files
% loop for ewach file
for i = 1:N
[num,txt,raw] = xlsread(S{i}) ; % read file, also use look into csvread
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!