Read from Excel file as a plain table
Show older comments
Hi everyone!
I have an excel file with the data like this:

The size (columns and rows quantity) is not defined and can be changed. Some data may be missing.
I want to get this table in Matlab as a simple table where every cell in the file is in a cell in the table. I do not need to use variable name read, to read in separate structures text and numerical data, or anything else. It will be more convenient to have only one variable as a table and then to get the required information and store it in a suitable variable format. For example, A4, A5, ... convert to datetime, to merge B1 and B2 into one string, numeric values as a matrix.
However, readtable() function always tries to do something with head, and I didn't find a way to skip it. The way like 'ReadVariableNames',false only do not read head, but I want to see it in the variable.
Could you please tell me what to do to import data from an excel file without such smart reading?
2 Comments
dpb
on 3 Nov 2020
The irregular nature of the arrangement in the spreadsheet is the primary culprit.
Why are there four (4) rows of data but only three (3) corresponding dates?
Creating the original file in a more consistent manner would simplify things a whole lot.
It will be simple enough to create the compound name from rows 1:2; what's not so clear is the remainder.
Walter Roberson
on 4 Nov 2020
readcell
Accepted Answer
More Answers (1)
drummer
on 3 Nov 2020
0 votes
Well, if you want to have this specific small table, then you could insert them in MATLAB manually.
Would it work?
If so, then you could use cell arrays and tell MATLAB the way you want the table, without the 'fancy' readtable features.
Again, bigger tables would not be ideal. But if you want this small one. I wonder that's ok.
This way, it will be ok to ignore the (relevant) observation from dpb.
Let us know if it worked for you.
Cheers
2 Comments
Egor Gurov
on 3 Nov 2020
I have never dealt with such table formation.
I'm not familiar with your dataset but if you use Name and parameter as categorical variables and each date as a single variable (like hot-encoding your date variables) would not work?
So you would have
Name (categorial) | Parameter (categorical) | ParameterOutput (numerical) | Date 1 | Date 2 | Date 3
Unless you're not looking to fix your table layout. rs
I wonder dpb suggestion would work if that's the case.
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!