how to read .sts file in matlab?

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?

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 5 Sep. 2013

1 Stimme

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

sandy
sandy am 10 Sep. 2013
thanks...i need to everything.if i use regexp() with split option,it breaking into fields into single line.but i need each parameter in a single cell includes everything as above mentioned order(because sts file contains 10min data stored in order,reference in above)....help needed here
another query is..my input will in one location(say folder name 'INPUT') this input files(sts file) are present there ,but i need to store my excel output in another location(say folder name 'OUTPUT'),whether it is possible if i use xlswrite?
Walter Roberson
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.
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);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Large Files and Big Data finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by