Skip to content

Commit

Permalink
arLoadData more robust
Browse files Browse the repository at this point in the history
replace deprecated matlab function xlsread by more robust readtable
  • Loading branch information
niklasneubrand committed Jun 12, 2024
1 parent 352ec22 commit 281fb6a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions arFramework3/arLoadData.m
Original file line number Diff line number Diff line change
Expand Up @@ -752,10 +752,16 @@ function arLoadData(name, m, extension, removeEmptyObs, varargin)
warning('off','all')

arFprintf( 3, '[ OK ]\nBegin reading data (xls) ...' );
if (exist([DataPath, name '.xls'],'file'))
[data, Cstr] = xlsread([DataPath, name '.xls']);
elseif (exist([DataPath, name '.xlsx'],'file'))
[data, Cstr] = xlsread([DataPath, name '.xlsx']);
if (exist([DataPath, name '.xls'],'file'))
dataTable = readtable([DataPath, name '.xls']);
data = table2array(dataTable);
Cstr = dataTable.Properties.VariableNames;
% [data, Cstr] = xlsread([DataPath, name '.xls']);
elseif (exist([DataPath, name '.xlsx'],'file'))
dataTable = readtable([DataPath, name '.xlsx']);
data = table2array(dataTable);
Cstr = dataTable.Properties.VariableNames;
% [data, Cstr] = xlsread([DataPath, name '.xlsx']);
end
arFprintf( 3, '[ OK ]\n' );

Expand Down

2 comments on commit 281fb6a

@clemenskreutz
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

readtable do not work after this change if there are columns with text, e.g. annotation

@niklasneubrand
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the comment. The issue should be fixed now.

Please sign in to comment.