how work with Datastore from two or more file excel sheets

조회 수: 3 (최근 30일)
Juan Carlos Pozuelos Buezo
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
Melody Lyu 2020년 2월 4일
Hi Juan,
which way did you end up using? I am having the same question too

댓글을 달려면 로그인하십시오.

채택된 답변

Jalaj Gambhir
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!
  댓글 수: 1
Juan Carlos Pozuelos Buezo
Juan Carlos Pozuelos Buezo 2019년 11월 15일
Thanks i will try.
another solution that i did, is make two data store, and join them after to use gather.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by