App Designer: Error using readtable "filename" must be a string scalar or character vector.
9 views (last 30 days)
Show older comments
Connor Fitzgerald
on 14 Jan 2021
Commented: Cris LaPierre
on 14 Jan 2021
Hello,
Please help me to resolve this issue I've been struggling with for hours on end.
My goal is to use multiselect to select several files and import them as tables to be manipulated independently via the GUI
app.ListBoxFileNames.Items = fileList
app.ListBoxPlotNames.Items
[file, path] = uigetfile('*.*','MultiSelect','on')
if noFiles == 1 % Code works for 1 file
initTable = readtable(file); % init table I think work with in the GUI
app.ListBoxFileNames.Items = fileList; % this is a cell
app.ListBoxPlotNames.Items = fileList;
else % Issues when using multiselect
for i=1:numel(file)
fileListNew = fileList(:,i)
% Below I try to use a structArray to contain a structure consisting of all the tables I import, as I don't know how else to work with the multiple tables
structArray(i) = table2struct(readtable((fileListNew))) % structArray(i)'s I would also like to work with independently in the GUI as separate tables.
app.ListBoxFileNames.Items{i} = fileList;
app.ListBoxPlotNames.Items{i} = fileList;
end
end
Any meaningful assistance would be appreciated. Thank you.
1 Comment
Accepted Answer
Cris LaPierre
on 14 Jan 2021
Edited: Cris LaPierre
on 14 Jan 2021
I suspect the error is with how you are indexing you file names.
First, what is fileList? Shouldn't you be using the files that were just selected? That's file, which is a cell arry. Try using curly braces to index your cell instead of parentheses.
structArray(i) = table2struct(readtable(file{i}));
5 Comments
Cris LaPierre
on 14 Jan 2021
You might consider a table of tables (see here). However, if you now have a clearer idea of how to organize your data, take the opportunity to do that.
More Answers (0)
See Also
Categories
Find more on Data Type Identification 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!