Export Sorted Columns to Existing File
1 view (last 30 days)
Show older comments
Hello, I am running through ~50 text files and read them in order to sort the columns of the data, however the problem arises in the printing/exporting of the data. I would like to overwrite the files that I am reading in with the new, sorted data, and thus do not want to have to specify an output file. My current codes is as follows.... slopef = dir('*.out'); numfiles = length(slopef); mydata = cell(1, numfiles);
for k = 1:numfiles %fid=fopen(slopef(k).name,'a+'); fid=fopen(slopef(k).name,'w'); mydata{k} = load(slopef(k).name);
temp=sort(mydata{k});
ds=mat2dataset(temp,'VarNames',{'YYYY','MM','DD','TMIN','TMAX','RAIN'});
%export(ds,'File','Nolables.txt','WriteVarNames',false)
fprintf(fid,ds.TMIN)
%csvwrite('blah',temp)
fclose(fid);
end
0 Comments
Answers (1)
See Also
Categories
Find more on Low-Level File I/O 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!