Read multiple csv files from a folder and not all csv files
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
KSSV
le 10 Jan 2019
Modifié(e) : KSSV
le 10 Jan 2019
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 commentaires
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!