使用python方式将regex条件移出日志文件

使用python方式将regex条件移出日志文件,python,regex,Python,Regex,我有一个需要提取的日志文件,我正在使用python中的regex方法来提取数据,但我无法找出提取这组文本的正确条件 目前的情况是选择不需要的文本,但仍然能够获得我需要的文本部分 希望有人能帮助我 以下是我使用的正则表达式条件: (Item|Chamber|DC|Etch|Depo)\s+[^:].+ 下面是我测试它的url: 示例日志文件: Nexus Cluster Tool Controller Process Data Log Version CTCflex V2.102.0

我有一个需要提取的日志文件,我正在使用python中的regex方法来提取数据,但我无法找出提取这组文本的正确条件

目前的情况是选择不需要的文本,但仍然能够获得我需要的文本部分

希望有人能帮助我

以下是我使用的正则表达式条件:

(Item|Chamber|DC|Etch|Depo)\s+[^:].+
下面是我测试它的url:

示例日志文件:

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

根据您的要求,Regex是:

(?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-]+)
祝你好运,谢谢你提出这么复杂有趣的问题!:)

你可以详细查一下,这比我认为的更方便

UPD:python 3脚本(只需获得正确的输入文件名):

重新导入
输入文件名='log.txt'
(1,3{1,3}3}w *){1,3{1,3}w *)1,5{(1,5)年(1,5)上述(r)编译(r)(r)(P(P)(P)(P(P)(P)(P)(P)(P(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(A)(A)(A)(A)(A)(A)(A)(A)(A)A)A(A(A)A)及及A)A(A(A)及及及)及及及及及)及及及(w(w(w)及)及)及(0-9]\[0-9e-]+)')
匹配=[]
将open(输入文件名“r”)作为f:
日志内容=f.读线()
对于日志内容中的行:
结果=重新匹配(图案、线条)
如果结果为:
匹配。追加(结果)
对于匹配的行:
打印(line.groupdict())

根据您的要求,Regex是:

(?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-]+)
祝你好运,谢谢你提出这么复杂有趣的问题!:)

你可以详细查一下,这比我认为的更方便

UPD:python 3脚本(只需获得正确的输入文件名):

重新导入
输入文件名='log.txt'
(1,3{1,3}3}w *){1,3{1,3}w *)1,5{(1,5)年(1,5)上述(r)编译(r)(r)(P(P)(P)(P(P)(P)(P)(P)(P(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(P)(A)(A)(A)(A)(A)(A)(A)(A)(A)A)A(A(A)A)及及A)A(A(A)及及及)及及及及及)及及及(w(w(w)及)及)及(0-9]\[0-9e-]+)')
匹配=[]
将open(输入文件名“r”)作为f:
日志内容=f.读线()
对于日志内容中的行:
结果=重新匹配(图案、线条)
如果结果为:
匹配。追加(结果)
对于匹配的行:
打印(line.groupdict())

能否显示实际(完整)相关的Python代码?您使用的是
re.search
还是
re.match
,还是其他什么?您好,我正在为当前任务使用re.match…我做得正确吗?
re.match
只匹配行开头的内容。看。您需要的是
re.search
。可能是的重复。您能显示实际(完整)相关的Python代码吗?您使用的是
re.search
还是
re.match
,还是其他什么?您好,我正在为当前任务使用re.match…我做得正确吗?
re.match
只匹配行开头的内容。看。您将需要
re.search
。可能与hi重复谢谢您的详细回复,但我无法正确编译?(P(项目|商会|商会|直流|直流|刻蚀|直流|直流|直流|直流|直流|刻蚀|蚀刻|沉积)政府当局(P{1,3}\1,3}\w*w*w*){1,5(1,5}((1,5)5(1,5)可能(1,5)5)可能(1.5)上述(1.5)上述(1.5)可能(1.5)上述((((((((mA(((mA(马(马124;A 124;A;A;A;A;A;A124;A;A;A;A;A;A;w;w;w;w;V;V;V;V;V;V124;V;0-9]\.[0-9e-]+”,myString,re.MULTILINE)print(h_regex.groupdict())您好,谢谢您的详细回复,但我无法正确编译它?(P(项目|商会|商会|直流|直流|刻蚀|直流|直流|直流|直流|直流|刻蚀|蚀刻|沉积)政府当局(P{1,3}\1,3}\w*w*w*){1,5(1,5}((1,5)5(1,5)可能(1,5)5)可能(1.5)上述(1.5)上述(1.5)可能(1.5)上述((((((((mA(((mA(马(马124;A 124;A;A;A;A;A;A124;A;A;A;A;A;A;w;w;w;w;V;V;V;V;V;V124;V;0-9]\.[0-9e-]+”,myString,re.MULTILINE)打印(h_regex.groupdict())