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

3 ビュー (過去 30 日間)
Valeria Leto
Valeria Leto 2021 年 11 月 14 日
コメント済み: Mathieu NOE 2021 年 11 月 19 日
How can I use importdata to import .csv files that are in a specific folder? Thanks

回答 (1 件)

Mathieu NOE
Mathieu NOE 2021 年 11 月 15 日
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
  1 件のコメント
Mathieu NOE
Mathieu NOE 2021 年 11 月 19 日
hello
how is it going ?
problem solved ?
all the best

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by