필터 지우기
필터 지우기

How to create multiple tables from a single spreadsheet

조회 수: 10 (최근 30일)
Federico Migliosi
Federico Migliosi 2021년 11월 17일
댓글: Dave B 2021년 11월 17일
I have a single .xlsx spreadsheet with multple tables on the same page, but one below the other.
The picture below shows an example.
From this spreadsheet I want to create two different tables at the same time. I have tried using the import tool or the readtable() function but I did not succeed.
Can someone help me?

채택된 답변

Dave B
Dave B 2021년 11월 17일
You can specify a range when calling readtable:
For example:
T = readtable('patients.xls',...
'Range','C2:E6',...
'ReadVariableNames',false)
If you attach your excel file we can help with it, but it's really as easy as specifying the excel column and row for the upper left and lower right corners.
  댓글 수: 2
Federico Migliosi
Federico Migliosi 2021년 11월 17일
Thank you for the quick response.
Your code will just create one table from the specified upper left and lower right corners.
I was looking for a way to create multiple tables at once, each with a couple of unique corners. For now I think I will just create the tables manually, each time specifing the correct corners.
I have attached the excel file if it helps.
Dave B
Dave B 2021년 11월 17일
Sadly, I don't think there's any way to create multiple tables with one call to readtable.
If you really wanted to you could write a little function that looped over a set of ranges to return multiple tables (just to make it easier to read), but you'd be faced with choosing whether the output should be a cell array of tables (?) or if you'd vary the number of output arguments based on the number of ranges. Both would be a little awkward IMO.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by