フィルターのクリア

Merging multiple file excel

2 ビュー (過去 30 日間)
Rachele Franceschini
Rachele Franceschini 2021 年 9 月 21 日
コメント済み: Mathieu NOE 2021 年 9 月 21 日
Hi, I have 1000 file excel with only two field in column: time and value.
I would like to merge in one excel file with only two columns.
There is something solution?

採用された回答

Mathieu NOE
Mathieu NOE 2021 年 9 月 21 日
hello Rachele
you can do this -
I used natsortfile (from FEX : https://fr.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort ) to make sure the data are grabbed from the files in their natural name sorting which is not what matlab does autmatically
clc
clearvars
fileDir = pwd;
outfile = 'OUT.xlsx'; % output file name
fileNames = dir(fullfile(fileDir,'data*.xlsx')); % get list of data files in directory
fileNames_sorted = natsortfiles({fileNames.name}); % sort file names into order (https://fr.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort)
M= length (fileNames_sorted);
out_data = [];
for f = 1:M
% option # 1 for numeric data only using importdata
raw = importdata( fullfile(fileDir, fileNames_sorted{f}));
% vertical contatenation of all individual files data
out_data = [out_data; raw.data];
end
% store out_data in excel file
writematrix(out_data,fullfile(fileDir,outfile));
  2 件のコメント
Rachele Franceschini
Rachele Franceschini 2021 年 9 月 21 日
Thank you!!!!
Mathieu NOE
Mathieu NOE 2021 年 9 月 21 日
my pleasure !

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

その他の回答 (1 件)

Mathieu NOE
Mathieu NOE 2021 年 9 月 21 日

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by