Filter löschen
Filter löschen

How can I use importdata to import .csv files in a specific folder?

1 Ansicht (letzte 30 Tage)
Valeria Leto
Valeria Leto am 14 Nov. 2021
Kommentiert: Mathieu NOE am 19 Nov. 2021
How can I use importdata to import .csv files that are in a specific folder? Thanks

Antworten (1)

Mathieu NOE
Mathieu NOE am 15 Nov. 2021
hello Valeria
this little code will open and read all csv files , once sorted by natural naming
(load the requested function natsortfiles at :
the results are stored as structure S.data
fileDir = pwd;
S = dir(fullfile(fileDir,'*.csv')); % get list of data files in directory
S = natsortfiles(S); % sort file names into natural order , see :
%(https://fr.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort)
for k = 1:length(S)
S(k).data = importdata( fullfile(fileDir, S(k).name));
end

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by