我有一个需要提取的日志文件,我在python中使用正则表达式来提取数据,但我无法找出提取文本的正确条件。
目前的情况是选择不需要的文字,但仍能获得我需要的部分文字。
希望有人可以帮助我。
这是我正在使用的正则表达式条件:
(Item|Chamber|DC|Etch|Depo)\s+[^:].+
这是我测试它的网址:
示例日志文件:
Nexus Cluster Tool Controller Process Data Log
Version CTCflex V2.102.00
Data Log Name: 2017-03-01_001_A2B
Tool ID: B
User ID: Maintenance-C
Run Number: 01
Number of Steps: 0
Schedule: DLCX_ARO2_6535_15A_PORD2=PRD
Run Date: 2017-03-01 (Y M D)
Run Start Time: 00:20:56
Wafer from LLA Slot 02 (Wafer ID:2017-03-01_001_A2B)
Module
Module : PM3 (DLCXIC)
PM Software Version : PMflex2008 (DLCX) Version 02.104.00.00
Process Name : PM3_ARO2_Ni35A_fillin_2AD2.prc
Step Number : 1
Step Name : CouponcheckD2
Step Time : 00:00:15.000
Run Time : 01Mar17 00:22:39
Chamber Pressure : 1.6e-006
Depo Source-DC Source Parameters
Use Source : False
Continuous Beam : False
Depo ControlMode : Continuous
Depo RegulationMode : Continuous
Depo RampTime (Sec) : 0.000
Depo Power (W) : 0.0
Depo Voltage (V) : 0.0
Depo JoulesQuantity : 0.0
Depo PulseMode : False
Depo PulseFrequency (kHz): 0.0
Depo PulseReverseTime (uS): 0.0
Depo ArcDetectEnabled : False
Depo ArcCountAlarm : 10000
Depo ArcResetDelay : 1
Depo Gas 1 Flow (SCCM) : 0.0
Depo Gas 2 Flow (SCCM) : 0.0
Etch Source Parameters
Use Source : False
Beam At Start : Shutoff
Beam At End : Shutoff
Neutralizer On : False
Continuous Beam : False
Beam Voltage (V) : 0.0
Beam Current (mA) : 0.0
Suppressor Voltage (V) : 0.0
Incident RF Power (W) : 0.0
K Factor : 0.0
Etch Gas 1 Flow (SCCM) : 0.0
Etch Gas 2 Flow (SCCM) : 0.0
Etch Gas 3 Flow (SCCM) : 0.0
PBN Gas Flow (SCCM) : 0.0
Source Magnet :
Use Source Magnet : False
Current (A) : 0.000
Control Parameters
Step Ends By : Time
Time Total Seconds : 15.000
End Pressure Setpoint : 2.0e-007
Power Down Sources : False
Fixture Parameters
Tilt Angle : -55.0
Rotate Fixture : True
Rotation Speed (RPM) : 30.0
Shutter Parameters
Depo Shutter At Start : Closed
Depo Shutter At Process : Closed
Depo Shutter At End : Closed
Etch Shutter At Start : Open
Etch Shutter At Process : Open
Etch Shutter At End : Open
Data Tracing Parameters
Tracing Enabled : True
Interval (Sec) : 1
Ellipsometer Parameters
Monitor : True
Step Type : View
Points or Angstroms : 4.0
Model Name : Model1
Process Results
Step Elapsed Time : 00:00:15.000
Step Remaining Time : 00:00:00.000
Process Statistics
Item Name Minimum Maximum Mean StdDev Median
Chamber Pressure 1.6e-006 1.7e-006 1.6e-006 2.5e-008 1.6e-006
DC Current Current (mA) 0.010 0.010 0.010 0.000 0.010
DC Current Impedance 0.000 0.000 0.000 0.000 0.000
DC Current Power (W) 0.000 0.000 0.000 0.000 0.000
DC Current Voltage (V) 0.000 0.000 0.000 0.000 0.000
Etch Beam Voltage (V) 4.746 4.746 4.746 0.000 4.746
Etch Beam Current (mA) 3.900 3.900 3.900 0.000 3.900
Etch Suppressor Voltage (V) 1.409 1.593 1.438 0.069 1.409
Etch Suppressor Current (mA) 0.000 0.000 0.000 0.000 0.000
Etch Forward RF Power (W) 0.000 0.000 0.000 0.000 0.000
Etch Reflected RF Power (W) 0.000 0.000 0.000 0.000 0.000
Etch PBN Filament (A) 0.104 0.110 0.105 0.002 0.104
Etch PBN Body (A) 0.001 0.002 0.002 0.001 0.002
Etch Source Magnet (A) 0.003 0.004 0.004 0.000 0.004
Depo Gas 1 Actual Flow (SCCM) 0.679 0.679 0.679 0.000 0.679
Depo Gas 2 Actual Flow (SCCM) 0.000 0.000 0.000 0.000 0.000
Etch Gas 1 Actual Flow (SCCM) 0.000 0.000 0.000 0.000 0.000
Etch Gas 2 Actual Flow (SCCM) 0.000 0.000 0.000 0.000 0.000
Etch Gas 3 Actual Flow (SCCM) 0.000 0.000 0.000 0.000 0.000
Etch PBN Gas Actual Flow (SCCM) 0.000 0.000 0.000 0.000 0.000
Events Which Occurred During The Process:
03/01/2017 00:22:10.279 U:Event: Current Process Recipe Name = PM3_ARO2_Ni35A_fillin_2AD2.prc [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.279 U:Event: Current Step Number = 1 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.279 U:Event: Current Step = CouponcheckD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.281 U:Event: Current Step Number = 2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.281 U:Event: Current Step = ArWarmupD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.283 U:Event: Current Step Number = 3 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.283 U:Event: Current Step = ArStableD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.284 U:Event: Current Step Number = 4 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.284 U:Event: Current Step = ArO2WarmupD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.286 U:Event: Current Step Number = 5 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.286 U:Event: Current Step = ArO2_EtchD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.288 U:Event: Current Step Number = 6 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.288 U:Event: Current Step = ArO2PurgeD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.290 U:Event: Current Step Number = 7 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.290 U:Event: Current Step = EtchwarmD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.292 U:Event: Current Step Number = 8 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.292 U:Event: Current Step = EtchstableD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.294 U:Event: Current Step Number = 9 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.294 U:Event: Current Step = PTREtch_6535D2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.296 U:Event: Current Step Number = 10 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.296 U:Event: Current Step = SiNstartD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.298 U:Event: Current Step Number = 11 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.298 U:Event: Current Step = SiNfillinD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.300 U:Event: Current Step Number = 12 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.300 U:Event: Current Step = SiNviewD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.301 U:Event: Current Step Number = 13 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.302 U:Event: Current Step = EtchbackNewD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.303 U:Event: Current Step Number = 14 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.303 U:Event: Current Step = SiNviewD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.305 U:Event: Current Step Number = 15 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.305 U:Event: Current Step = SiNstartD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.306 U:Event: Current Step Number = 16 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.306 U:Event: Current Step = SiNdepo_2AD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.308 U:Event: Current Step Number = 17 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.308 U:Event: Current Step = SiNviewD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.472 U:Event: Current Step Number = 1 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.472 U:Event: Current Step = CouponcheckD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.475 U:Event: Waiting for Process Pressure [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.660 U:Event: Waiting for Process Start Pressure [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.821 U:Event: Process Starting [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:10.821 U:Event: Waiting for Source PreStart [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:13.743 U:Event: Clamping Wafer for Processing [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:22.500 U:Event: Wafer is clamped for Processing [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:22.955 U:Event: Configuring Rotation Axis to Step Configuration [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:23.001 U:Event: Sequence MotionToInitialPosition - Moving Fixture to process position [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:42.232 U:Event: Waiting for Step to Complete [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:57.041 U:Event: Step Completed. [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:58.002 U:Event: Current Step Number = 2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:58.003 U:Event: Current Step = ArWarmupD2 [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:59.312 U:Event: Configuring Rotation Axis to Step Configuration [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:22:59.398 U:Event: Sequence MotionToInitialPosition - Moving Fixture to -135 degrees [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:23:09.269 U:Event: Sequence MotionToInitialPosition - Moving Etch Shutter to Initial Position [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:23:15.622 U:Event: SourceManager RF Generator Status Update: External Interlock - OK [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:23:15.758 U:Event: Etch : Ramping Started [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:23:17.767 U:Event: Etch: Gas is stable... [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:23:25.779 U:Event: Etch: Turning On RF [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:23:39.709 U:Event: Etch: Igniting Beam... [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:23:40.797 U:Event: Etch: Waiting for the beam to stabilize/regulate... [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:23:44.370 U:Event: Etch: Beam stabilized/regulated. [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:23:46.120 U:Event: Source 'SourceManager_Etch' has indicated an error. [LLA_02] [2017-03-01_001_A2B]
Alarms Which Occurred During The Process:
03/01/2017 00:23:46.013 U:Alarm: Etch: Maximum Suppressor Current Limit Detected (SI=0.298)! [LLA_02] [2017-03-01_001_A2B]
03/01/2017 00:23:46.120 U:Alarm: Sequence IgniteBeam - Failed to Ignite all Sources [LLA_02] [2017-03-01_001_A2B]
Data Log Event: Process Aborted
Process has been abnormally terminated. - 03/01/2017 00:23:46.251
Processing should be continued from:
Process Name: PM3_ARO2_Ni35A_fillin_2AD2.prc
Step Name: ArWarmupD2
Step Number: 2
Elapsed Time: 0.000
Remaining Time: 60.000
Total Steps: 17
以下是我想逐步提取的样本部分:
Item Name Minimum Maximum Mean StdDev Median
Chamber Pressure 1.6e-006 1.7e-006 1.6e-006 2.5e-008 1.6e-006
DC Current Current (mA) 0.010 0.010 0.010 0.000 0.010
DC Current Impedance 0.000 0.000 0.000 0.000 0.000
DC Current Power (W) 0.000 0.000 0.000 0.000 0.000
DC Current Voltage (V) 0.000 0.000 0.000 0.000 0.000
Etch Beam Voltage (V) 4.746 4.746 4.746 0.000 4.746
Etch Beam Current (mA) 3.900 3.900 3.900 0.000 3.900
Etch Suppressor Voltage (V) 1.409 1.593 1.438 0.069 1.409
Etch Suppressor Current (mA) 0.000 0.000 0.000 0.000 0.000
Etch Forward RF Power (W) 0.000 0.000 0.000 0.000 0.000
Etch Reflected RF Power (W) 0.000 0.000 0.000 0.000 0.000
Etch PBN Filament (A) 0.104 0.110 0.105 0.002 0.104
Etch PBN Body (A) 0.001 0.002 0.002 0.001 0.002
Etch Source Magnet (A) 0.003 0.004 0.004 0.000 0.004
Depo Gas 1 Actual Flow (SCCM) 0.679 0.679 0.679 0.000 0.679
Depo Gas 2 Actual Flow (SCCM) 0.000 0.000 0.000 0.000 0.000
Etch Gas 1 Actual Flow (SCCM) 0.000 0.000 0.000 0.000 0.000
Etch Gas 2 Actual Flow (SCCM) 0.000 0.000 0.000 0.000 0.000
Etch Gas 3 Actual Flow (SCCM) 0.000 0.000 0.000 0.000 0.000
Etch PBN Gas Actual Flow (SCCM) 0.000 0.000 0.000 0.000 0.000
答案 0 :(得分:0)
您的请求的正则表达式是:
(?P<Item>(Item|Chamber|DC|Etch|Depo)(\s{1,3}\w*){1,5}(\((mA|A|W|V|SCCM)\))?)\s{4,}(?P<minimum>[0-9]\.[0-9e-]+)\s+(?P<maximum>[0-9]\.[0-9e-]+)\s+(?P<mean>[0-9]\.[0-9e-]+)\s+(?P<stddev>[0-9]\.[0-9e-]+)\s+(?P<median>[0-9]\.[0-9e-]+)
通过这种方式,您将拥有6个正则表达式命名组:item
,minimum
,maximum
mean
,stddev
和median
您可以通过groupdict()
方法在python代码中提取。
如果您正在使用网站检查正则表达式(在python中MULTILINE
),也不要忘记启用re.MULTILINE
标记。
这就是groupdict()
方法的工作原理:
import re
h_regex = re.match(r'(?P<hello>H)', 'Hello', re.MULTILINE)
print(h_regex.groupdict())
祝你好运,感谢这样复杂而有趣的问题! :)
您可以在http://pythex.org/中查看详细信息,在我看来比http://myregexp.com/更方便。
UPD: python 3脚本(只需输入正确的输入文件名):
import re
input_filename = 'log.txt'
pattern = re.compile(r'(?P<item>(Item|Chamber|DC|Etch|Depo)(\s{1,3}\w*){1,5}(\((mA|A|W|V|SCCM)\))?)\s{4,}(?P<minimum>[0-9]\.[0-9e-]+)\s+(?P<maximum>[0-9]\.[0-9e-]+)\s+(?P<mean>[0-9]\.[0-9e-]+)\s+(?P<stddev>[0-9]\.[0-9e-]+)\s+(?P<median>[0-9]\.[0-9e-]+)')
matched = []
with open(input_filename, 'r') as f:
log_content = f.readlines()
for line in log_content:
result = re.match(pattern, line)
if result:
matched.append(result)
for line in matched:
print(line.groupdict())