I am trying to read a data from a file, modify it and write to a same file which I did using,
fid = fopen('file.ext','r');fclose(fid);lines = textscan(fid,'%s','Delimiter','\n');...fid = fopen('file.ext','w');for row = 1:length(lines{1}) fprintf(fid,'%s\n',lines{1}{row});endfclose(fid);
But I could not reproduce the indents which were in the original file. So any suggestions to achieve this and make the above process easier?
Note: the file extension is not .txt but similar to text format. The data which I try to read has html tag elements and attributes.
I would also like to know whether there is any way to directly modify a file without reading it?
Thanks in advance!
Best Answer