How to remove header lines in .txt file?

8 次查看(过去 30 天)
following text are in my file.
% CAPS-DAQ Version = 1.5.8
% CAPS software (c) Aerodyne Research, Inc.
% version: 0.9.18
% os: 3.10.17-1.0.0-technologic+g86f7675
% Product: CAPS SSA Monitor
% Auto. Baseline is On
% Auto. Baseline Interval = 0 HOURS 15 MINUTES , starting 13 HOURS 11 MINUTES
% Autosave is On
% Autosave Interval = 00 HOURS 01 MINUTES , starting 00 HOURS 01 MINUTES
% Divisors : 588 589 692664 294
% Mean Frequency = 16.99
% IF Frequency = 28.87
% Exact Sample Time = .90
% 12 744 80 1
% 742 17 15 10
% 40 3 5 3
% 104 131 99 650
% 0 77 1.4400e+01 100
% 0.0000e+00 313150 1.2500e+02 1
% 7.3000e-01 5.0071e+02 0 1.2669e+01
% 5120 111 135 318003
% 5.8981e+04 2 2.0098e+03 2.4327e+05
% 5.1338e+02 1.1200e+00 81873 DHCP
% 10.100.1.39 caps-318002 40 1
% 5 3.0422e+05 7.4468e+02 1.1367e+00
% 1.9064e+04 9.7389e-01 1.3609e+02 10000
% -15 588 26 5
% 2 2 141 13
% 0 294 1.9200e+00 6.4000e+00
% 1 2017-2-17_at_13:40 9.7286e-01 2017-10-19_at_11:37
% 2.0781e+00 2017-09-01 -1.0972e+01 01-Jan-1970
% -1.1177e-35 08-Mar-2016 -3.6882e-22 01-Jan-1970
% 0.0000e+00 1.0770e+00 1.3000e-04 9.6000e-01
IgorTime,Extinction,Scattering,Loss,Pressure,Temperature,Signal,LossRef,Status,WC,SignalRef,RawScatRef,RawScat,SDR,WCRef,Timestamp
3643055998.07,106.869,86.547,593.571,743.61,306.76,50650,503.011,10135,0.977,57538.475,19605.675,24526,2887,0.974,2019/06/11 00:00:00.334
3643055999.07,97.727,88.299,586.890,743.14,306.76,51058,503.011,10135,0.977,57538.475,19605.675,25117,2887,0.974,2019/06/11 00:00:01.349
3643056000.06,94.503,79.614,584.560,744.59,306.76,51408,503.011,10135,0.977,57538.475,19605.675,24446,2887,0.974,2019/06/11 00:00:02.333
3643056001.06,87.193,75.832,579.207,743.61,306.77,51654,503.011,10135,0.977,57538.475,19605.675,24336,2887,0.974,2019/06/11 00:00:03.333
3643056002.06,102.930,91.036,590.694,743.51,306.76,50880,503.011,10135,0.977,57538.475,19605.675,25186,2887,0.974,2019/06/11 00:00:04.333
3643056003.06,86.191,75.300,578.480,743.82,306.75,51706,503.011,10135,0.977,57538.475,19605.675,24327,2887,0.974,2019/06/11 00:00:05.333
3643056004.06,114.473,97.242,599.117,743.30,306.76,50280,503.011,10135,0.977,57538.475,19605.675,25251,2887,0.974,2019/06/11 00:00:06.349
3643056005.06,84.862,76.239,577.511,743.97,306.77,51899,503.011,10135,0.977,57538.475,19605.675,24542,2887,0.974,2019/06/11 00:00:07.333
3643056006.06,83.313,73.150,576.383,744.07,306.76,51927,503.011,10135,0.977,57538.475,19605.675,24263,2887,0.974,2019/06/11 00:00:08.333
3643056007.06,96.967,84.593,586.338,743.30,306.75,51209,503.011,10135,0.977,57538.475,19605.675,24817,2887,0.974,2019/06/11 00:00:09.333
3643056008.06,83.455,73.530,576.479,743.61,306.76,51882,503.011,10135,0.977,57538.475,19605.675,24281,2887,0.974,2019/06/11 00:00:10.333
3643056009.06,82.796,75.103,575.991,743.14,306.75,51978,503.011,10135,0.977,57538.475,19605.675,24506,2887,0.974,2019/06/11 00:00:11.348

采纳的回答

KSSV
KSSV 2019-6-21
REad about textscan; here you can provide the number of header lines.

更多回答(1 个)

Kojiro Saito
Kojiro Saito 2019-6-21
I'm not sure about your MATLAB version, but from R2016b, you can use delimitedTextImportOptions which can be called with detectImportOptions.
I assume You have a text file in which top 33 lines are header and line 34 is a column name, so the following will work.
opts = detectImportOptions('your.txt', 'NumHeaderLines', 33);
t = readtable('test.txt', opts);
Then, you can get 12x16 table.

产品

Community Treasure Hunt

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

Start Hunting!

Translated by