Read multiple csv files from a folder and not all csv files
3 次查看(过去 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!