Appending to text files
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello, this is a fairly simple problem and i have come up with a simple enough solution. I need to append alot of text files to one master file.
i did this
clear all
clc
fid=fopen('t1.txt','a+');
fod=fopen('t2.txt');
while ~feof(fod)
fprintf(fid,'\n%s',(fgetl(fod)));
end
fclose('all');
Pretty simple right? It works well too. It appends everything in t2.txt to t1.txt. I have a suspision their is a better way to do this task though. The end of file identifier is what annoys me. Has anyone got a better way?
0 comentarios
Respuestas (1)
Walter Roberson
el 12 de Mzo. de 2012
Please see my comments in http://www.mathworks.com/matlabcentral/answers/22289-read-an-input-file-process-it-line-by-line
short summary: feof() never predicts end of file.
0 comentarios
Ver también
Categorías
Más información sobre Other Formats en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!