using fullfile when you need to pass a string as an input argument with readable TreatAsEmpty
Show older comments
Hi,
I have a folder of files which have strings as headers and when there are fields which the measuring system could not measure it fills those fields with a string ('UND. -62011'), I have been using
Folder_used = dir('/Users/username/Desktop/data/*.txt');
files = Folder_used;
for k=1:numel(files)
data=readtable(files(k).name,'FileType','text',...
'Delimiter','tab','TreatAsEmpty',["UND. -60001","UND. -2011","UND. -62011"]);
%do stuff
end
which works fine. When I want to put this in a standalone app I have a problem. I need to use fullfile to pass the location of the directory and then have the user select the folder, then combine them
i assign the directory as A1 having after having converted it to a string
for k=1:numel(files)
full_name=fullfile(A1,files(k).name)
data=readtable(full_name,'FileType','text',...
'Delimiter','tab',...
'TreatAsEmpty',{'UND. -60001','UND. -2011','UND. -62011'});
but get the error
*Error using fullfile (line 51) String input not supported.
Error in tool/rows3d_Callback (line 157) full_name=fullfile(A1,files(k).name)
Error while evaluating UIControl Callback.*||||
Is there a way to use/get around the read table TreatAsEmpty argument with a string input and use fullfile?
Best regards,
Steve
Accepted Answer
More Answers (0)
Categories
Find more on Characters and Strings 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!