Read multiple csv files from a folder and not all csv files

3 Ansichten (letzte 30 Tage)
Sandeep Nair
Sandeep Nair am 10 Jan. 2019
Bearbeitet: KSSV am 10 Jan. 2019
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?

Antworten (1)

KSSV
KSSV am 10 Jan. 2019
Bearbeitet: KSSV am 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

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by