Create .txt file and open dialog for saving-path

2 views (last 30 days)
Hello, how can I use the function "writetable" in a way, that it opens a dialog and asks me where to save the newly generated ".txt"-file? With "iuputfile"?

Accepted Answer

Jan
Jan on 29 Jul 2015
You can't. This is a job for uiputfile.
[FileName, PathName, FilterIndex] = uiputfile('*.txt', 'Save table as:');
if ~ischar(FileName)
disp('User aborted the dialog');
return;
end
File = fullfile(PathName, FileName);
writetable(T, File);
  1 Comment
Ali Afruzi
Ali Afruzi on 6 Feb 2021
Thank you @Jan
Someon also can use
[FileName, PathName, FilterIndex] = uiputfile('*.txt', 'Save table as:');
if ischar(FileName)
File = fullfile(PathName, FileName);
writetable(T, File);
else
disp('User aborted the dialog');
end
without using 'return'.

Sign in to comment.

More Answers (1)

Felix Ludwig
Felix Ludwig on 30 Jul 2015
figured it out by myself
[filename, pathname]=uiputfile('*.txt','Save');
vname=@(x) inputname(1);
i=vname(Table_1);
filename=[pathname i '.txt'];
writetable(Table_1,filename,'Delimiter','\t');

Categories

Find more on Develop uifigure-Based Apps 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!