readtable decide which coloumns are read as string and which as number. xlsx file

4 次查看(过去 30 天)
Hi
Im trying to read an xlsx table, but readtable gives me the wrong format. some of my coloums are read as numbers and not strings. Thereby returning a NAN instead of the string i needed. My question. is there a way to force the datatype on readtable?
here is an example of how my data is set together in my input table
after reading into readtable it looks like this
RT = readtable("file.xlsx")
and here is the output

采纳的回答

Arif Hoq
Arif Hoq 2022-3-24
编辑:Arif Hoq 2022-3-24
i have tried to make your excel and applied readtable function..see the result.
A=readtable('example_2.xlsx','ReadVariableName',false);
  2 个评论
Magnus Rasmussen
Magnus Rasmussen 2022-3-24
This is one way of solving it. Thank you very much.
I managed to solve the issue myself actually.
explanation: my datasheet had a lot empty cells between the string cells. I filled them out with string element "NE". This way each coloums contained a majority of string instead of numbers and blanks. Thereby readtable recognized the entire coloums as strings instead of numbers.
Thank you for your time

请先登录,再进行评论。

更多回答(1 个)

Peter Perkins
Peter Perkins 2022-3-24
Magnus, detectImportOptions and subsequent modifications on what it returns are what you are looking for. You can set any or all of the variable types, and a whole lot more.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by