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

조회 수: 3(최근 30일)
Magnus Rasmussen
Magnus Rasmussen 2022년 3월 24일
답변: Peter Perkins 2022년 3월 24일
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

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

추가 답변(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.

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by