Scan a text file for some data

3 views (last 30 days)
Saeed
Saeed on 29 Nov 2012
Hello
I need to scan a complected text file to find the values like date and time, and some peaks in certain moments. Can you please tell me how to do that? The text files are like this (GC results)
As an example the data I want is SIG10001.D in the first line. the date in line 5: 11/22/2012 13:54:49 PM
and some other values in next lines, I believe I will handle them after I learn these two ones.(They may not shown correctly in this text)
Best regards
Saeed
Data File C:\HPCHEM\1\DATA\TOMEPROD\SIG10001.D Sample Name: Distillate
AGILENT 6850 11/22/2012 14:08:50 PM SAEED
=====================================================================
Injection Date : 11/22/2012 13:54:49 PM Seq. Line : 1
Sample Name : Distillate Location : -
Acq. Operator : SAEED Inj : 1
Inj Volume : No inj
Sequence File : D:\HPCHEM\1\SEQUENCE\TOME.S
Method : C:\HPCHEM\1\METHODS\TAEEVAL.M
Last changed : 11/16/2012 10:06:50 PM by SAEED
=====================================================================
Area Percent Report
=====================================================================
Sorted By : Signal
Multiplier : 1.0000
Dilution : 1.0000
Use Multiplier & Dilution Factor with ISTDs
Signal 1: FID1 A,
Peak RetTime Type Width Area Height Area
# [min] [min] [pA*s] [pA] %
----|-------|----|-------|----------|----------|--------|
1 4.994 PV 0.0301 668.93677 352.99020 0.23606
2 5.078 VB S 0.0935 5.29838e4 9160.61914 18.69718
3 5.278 BB X 0.0419 246.37656 87.31703 0.08694
4 5.483 BB X 0.0401 55.78785 21.58883 0.01969
5 5.676 BP 0.0414 104.80035 38.91515 0.03698
6 5.997 BV 0.0535 198.18703 50.80287 0.06994
7 6.064 VB 0.0451 220.76306 71.43374 0.07790
8 6.482 BV 0.0753 54.96251 9.97957 0.01940
9 6.614 VB 0.0479 281.33212 88.89796 0.09928
10 6.918 PP 0.0517 28.16792 7.52760 0.00994
11 7.113 VB 0.0406 88.62502 32.68439 0.03127
12 7.329 BP 0.0404 143.04147 54.97429 0.05048
13 7.504 BB 0.0421 54.26121 19.71564 0.01915
14 7.643 BP 0.0419 10.87538 3.98018 0.00384
15 7.924 BV 0.0548 33.04194 9.68445 0.01166
16 8.030 VV 0.0450 30.85688 10.57947 0.01089
17 8.390 BP 0.0460 88.78347 29.57019 0.03133
18 8.957 BP 0.0767 37.62064 7.60910 0.01328
19 9.575 PV S 0.0749 1.90900e5 3.38004e4 67.36582
20 9.696 BV X 0.0281 74.65408 41.37165 0.02634
21 9.842 VB S 0.0425 3.11354e4 1.08496e4 10.98719
22 10.007 BV X 0.0301 120.74277 63.69372 0.04261
23 10.063 VB X 0.0328 370.84274 174.30756 0.13086
24 10.242 BB X 0.0329 166.80324 78.30387 0.05886
25 10.524 BB 0.0337 121.31771 57.35064 0.04281
26 10.681 BP 0.0338 364.72791 171.52573 0.12871
27 11.018 BV 0.0333 72.04418 34.54771 0.02542
28 11.757 BP 0.0313 90.24658 45.13648 0.03185
29 12.077 BB 0.0307 12.24738 6.28417 0.00432
30 12.429 PV 0.0288 44.58385 23.83980 0.01573
31 12.489 VP 0.0313 138.53285 69.32865 0.04889
32 12.780 BB 0.0350 243.65657 101.44206 0.08598
33 12.908 BP 0.0291 25.89804 13.64151 0.00914
34 13.250 BB 0.0317 4093.44043 2016.99573 1.44451
35 13.431 BP 0.0345 58.33971 25.72445 0.02059
36 13.943 PBA 0.0422 14.61536 5.13776 0.00516
Totals : 2.83379e5 5.76375e4
=====================================================================
Summed Peaks Report
=====================================================================
Signal 1: FID1 A,
=====================================================================
Final Summed Peaks Report
=====================================================================
Signal 1: FID1 A,
*** End of Report ***

Answers (1)

dpb
dpb on 29 Nov 2012
Basically,
doc textscan
You can parse the file given what you know that is fixed format and what fields you wish to retrieve...
To get the initial file name...
fid=fopen('thefile','rt'); fn=textscan(fid,' Data File %s %*[^\n]');
You can then do a new read w/ textscan on the same fid and use the appropriate number of 'headerline', 'N' to skip to the desired record and read it...
It didn't appear that the date you were interested in was actually on line 5; perhaps owing to line wrap problems but you can work those details out...
--

Community Treasure Hunt

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

Start Hunting!