MATLAB: Edit txt file but save previous data

edit txttxtwritetable

helo guys
I generated a table , wrote in a txt file, and when I run again my code I will choose other file, it will write a new table… I want add this table in that same txt file which was the information of first table.
I did this at the end of program;
fid=fopen('dataFULL.txt','a+');
writetable(T,'dataFULL.txt','Delimiter',',');
fclose(fid);
when I run my code twice in order to choose other file… it is rewriting my txt file and doesn't save the previous data :((((((((((
Guys… any idea how can I do this?

Best Answer

" If filename is the name of an existing text file, then writetable overwrites the file."
You can't with it. Since writetable opens the file using the file name and doesn't accept a file handle, the fopen in your code snippet above is totally ineffective; the two have nothing whatever in common with each other as far as what is written to the file; there are instead two totally independent file handles created/destroyed, the one explicitly is never used for anything.
Again as another question just a minute ago, seems like a reasonable enhancement request would be in order.