how to read .sts file in matlab?
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
hi..i have .sts file(45000). i need to read this files in a loop and append them into an excel file. in each .sts file,it contains data like below,
SAMPLE_20130606_0006 0 +6.470299E+0 +4.009076E+0 +1.699308E+1 +1.095633E+0
SAMPLE_20130606_0016 0 +6.938715E+0 +2.954977E+0 +1.125970E+1 +1.396087E+0
SAMPLE_20130606_0026 0 +8.297382E+0 +4.155266E+0 +2.333013E+1 +1.611527E+0
SAMPLE_20130606_0036 0 +8.837934E+0 +5.234266E+0 +1.352240E+1 +1.407429E+0
SAMPLE_20130606_0046 0 +8.098710E+0 +3.642447E+0 +1.205176E+1 +1.683126E+0
how to read this file in a loop and save in excel format?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 5 Sep. 2013
xlswrite() for the file writing.
When you read the data, do you want all fields (including the text line), or do you only want the numbers? Perhaps only the last 4 numbers?
If you want everything, just broken out into fields, the consider using fileread() to read the file, and regexp() with 'split' option to break it into fields.
3 Kommentare
Walter Roberson
am 10 Sep. 2013
Use fullfile() to construct the input and output file names. xlswrite() will be perfectly happy to be given a file name in a different directory.
Walter Roberson
am 10 Sep. 2013
indir = 'INPUT';
outdir = 'OUTPUT';
finfo = dir(fullfile(indir, '*.sts'));
massoutput = {};
for K = 1 : length(finfo);
thisfilename = fullfile(indir, finfo(K).name);
sts = fileread(thisfilename);
t = regexp(regexp(regexprep(sts, ' *\n *$', ''), ' *\n', 'split'), '\s+', 'split');
massoutput{K} = vertcat(t{:});
end
massoutput = vertcat(massoutput{:});
thisfilename = fullfile(outdir, 'allsts.xls');
xlswrite(thisfilename, massoutput);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!