Created
September 11, 2020 10:19
-
-
Save kkt-ee/8981914cd08558c4170fdf6781a9a591 to your computer and use it in GitHub Desktop.
MATLAB read all csv files from a directory (eg. dirx)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% | |
pathx = '/root/dirx/'; %---o directory path | |
files = fullfile(pathx,'*.csv'); | |
d = dir(files); clearvars files | |
%% | |
files_with_abs_path = {}; | |
file_name_head ={}; | |
for k=1:numel(d) %---o LOOPING through each filenames | |
% | |
files_with_abs_path{k,1} = fullfile(pathx,d(k).name); | |
file_name_head{k,1}=strtok(d(k).name,'.'); %---o 'strtok'- selects parts of the string(string token); can be useful for creating 'variable name' | |
end | |
% | |
file_name = strcat(file_name_head,'.csv'); | |
% | |
whos files_with_abs_path file_name_head file_name | |
clearvars k d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment