readtable doesn`t work as prior version (2018b vs 2023a)

조회 수: 27 (최근 30일)
동철
동철 2023년 3월 28일
댓글: Walter Roberson 2023년 3월 28일
readtable function @2018b can read blank and numbers as text.
but @2023a cannot read like @2018b
Matlab says "you can use 'T = readtable(filename,'Format','auto')'.", but it doesn`t work at all.
Is there any other way to use readtable function @2023a like 2018b??
Para_A = readtable(app.FileEditField.Value,'sheet', 'A'); # @2018b
Para_A = readtable(app.FileEditField.Value,'sheet', 'A', 'Format', 'auto'); # @2023a --> does not work.

채택된 답변

Walter Roberson
Walter Roberson 2023년 3월 28일
Use detectImportOptions to create an options structure. Use setvartype() on the structure to set the column to be either char or string. Now readtable passing in the options structure
  댓글 수: 2
동철
동철 2023년 3월 28일
Thank you for reply!
I did use 'opts' by detectImportOptions and setvartype, but then readtable didn`t work.
opts = detectImportOptions(A.xlsx, 'sheet', 'Constant','VariableNamesRange',1,'DataRange', 'A2'); % passed
opts = setvartype(opts,{'Type','Name','Unit','Description'},'string'); % passed
Tab_Param = readtable(A.xlsx,opts); % error occured
Or, is there any way to use just like 2018b? (Matlab just recommend use below phrase.)
T = readtable(filename,'Format','auto') % error occured ("Cannot open spreadsheet")
Walter Roberson
Walter Roberson 2023년 3월 28일
filename = "A.xlsx";
opts = detectImportOptions(filename, 'sheet', 'Constant','VariableNamesRange',1,'DataRange', 'A2');
opts = setvartype(opts,{'Type','Name','Unit','Description'},'string');
Tab_Param = readtable(filename,opts);

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by