how work with Datastore from two or more file excel sheets
3 ビュー (過去 30 日間)
古いコメントを表示
Juan Carlos Pozuelos Buezo
2019 年 11 月 11 日
コメント済み: Melody Lyu
2020 年 2 月 4 日
Hi.
I want to work with many Excel files, and I tried to work with the Data Store. The problem is that I need data from two excel sheets, with different amounts of columns, and that the ds file groups them into a single table. the fixed work of the leaves are the same, only the columns are different.
How should I write the Datastore code to read both sheets and create a single tall array for everything?
Thank you.
1 件のコメント
Melody Lyu
2020 年 2 月 4 日
Hi Juan,
which way did you end up using? I am having the same question too
採用された回答
Jalaj Gambhir
2019 年 11 月 15 日
Hi,
I don't think that is possible using Datastore, but one possible workaround could be:
path = 'Source';
files = dir(fullfile(path, '*.xlsx'));
result = table();
filecontent = readtable(fullfile(path, files(1).name));
filecontent2 = readtable(fullfile(path, files(2).name));
vars1 = [filecontent.Properties.VariableNames]
vars2 = [filecontent2.Properties.VariableNames]
R = {[vars1 vars2]}
result = array2table([table2array(filecontent) table2array(filecontent2)],'VariableNames',R{:});
Hope this helps!
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!