SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 5 of 5
  1. #1
    Junior Member
    Join Date
    Nov 2008
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Extracting lines with regular expression

    Hi there,
    Hope you can help me as I am struggling in finding a solution for this.

    I'd like to extract the part of the log highlighted below.
    Every "debug" and "info" line of the log has date and time, which is good (I can extract this with regular expression, in the example below time constraint is 09:35 and 09:36) but the problem is that I would like to extract also lines starting with <GetPartyNameAddressRequest and <UpdatePartyHistoryRequest WHICH HAVE NO DATE.



    Here is the log, in red the part I want to extract:

    [DEBUG] 2011-10-28 09:25:22,357 (http-8080-Processor23:78679522-3812-4468-B889-64F42DAEE381:1865697111) org.apache.jsp.HandleGVPHangup_jsp.Main() Not writing call to DB.

    [DEBUG] 2011-10-28 09:27:58,357 (http-8080-Processor23:78679522-3803-4468-B889-64F42DAEE381:1865697110) org.apache.jsp.HandleGVPHangup_jsp.Main() Not writing call to DB.

    <font color="red">[DEBUG] 2011-10-28 09:35:45,357 (AWT-EventQueue-0:AF5A1B6B-4EAB-4B24-8A72-DD52D860D93E:2072070248) com.speechstorm.integration.IntelliConfig.updateCh eckSum() No Checksum Changes. Retaining Configuration File.

    [INFO ] 2011-10-28 09:36:22,498 (http-8080-Processor24:212F0AA3-347A-4AE5-93D1-4BA88B8C1B4F:1865697110) com.speechstorm.sky.integration.ecrm.mq.MQTranspor t.sendSyncMessage() Creating initial context...

    [DEBUG] 2011-10-28 09:36:23,342 (http-8080-Processor24:212F0AA3-347A-4AE5-93D1-4BA88B8C1B4F:1865697110) com.speechstorm.sky.integration.ecrm.mq.MQTranspor t.sendSyncMessage() Raw message reply for [&lt;?xml version="1.0" encoding="UTF-8"?&gt;


    &lt;GetPartyNameAddressRequest xmlns="http://CRM.bskyb.com/2008/03/15/CRMGVPTelephonyService"&gt;&lt;Session&gt;&lt;Cach eType&gt;BLOB_DB&lt;/CacheType&gt;&lt;/Session&gt;&lt;PartyID&gt;11582396311490015236645& lt;/PartyID&gt;&lt;/GetPartyNameAddressRequest&gt;] was [&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;NS1:GetPartyNameAddressResponse xmlns:NS1="http://CRM.bskyb.com/2008/03/15/CRMGVPTelephonyService"&gt;&lt;NS1:Session&gt;&lt; NS1:ID&gt;NCI73351009&lt;/NS1:ID&gt;&lt;NS1:CacheType&gt;BLOB_DB&lt;/NS1:CacheType&gt;&lt;/NS1:Session&gt;&lt;NS1:ResultCode&gt;Success&lt;/NS1:ResultCode&gt;&lt;NS1:Customer&gt;&lt;NS1:Part yID&gt;11582396311490015236645&lt;/NS1:PartyID&gt;&lt;NS1:Title&gt;MISS&lt;/NS1:Title&gt;&lt;NS1:Forename&gt;Geisha&lt;/NS1:Forename&gt;&lt;NS1:Surname&gt;Hussmann&lt;/NS1:Surname&gt;&lt;NS1ateOfBirth&gt;01011980&lt;/NS1ateOfBirth&gt;&lt;NS1:Priority&gt;STANDARD&lt;/NS1:Priority&gt;&lt;/NS1:Customer&gt;&lt;NS1:Address&gt;&lt;NS1:ID&gt;1 1582396312530015236649&lt;/NS1:ID&gt;&lt;NS1:AddressIndicator&gt;PRIMARY&lt;/NS1:AddressIndicator&gt;&lt;NS1:Validated&gt;true& lt;/NS1:Validated&gt;&lt;NS1:HouseNumber&gt;1&lt;/NS1:HouseNumber&gt;&lt;NS1:Street&gt;The Paddock&lt;/NS1:Street&gt;&lt;NS1:Town&gt;NORTH BERWICK&lt;/NS1:Town&gt;&lt;NS1:County&gt;East Lothian&lt;/NS1:County&gt;&lt;NS1:CountryCode&gt;GBR&lt;/NS1:CountryCode&gt;&lt;NS1:PostCode&gt;EH395AD&lt;/NS1:PostCode&gt;&lt;/NS1:Address&gt;&lt;/NS1:GetPartyNameAddressResponse&gt;]


    [INFO ] 2011-10-28 09:36:45,045 (http-8080-Processor23:212F0AA3-347A-4AE5-93D1-4BA88B8C1B4F:1865697110) com.speechstorm.sky.integration.ecrm.mq.MQTranspor t.sendSyncMessage() Creating initial context...

    [INFO ] 2011-10-28 09:36:45,060 (http-8080-Processor23:212F0AA3-347A-4AE5-93D1-4BA88B8C1B4F:1865697110) com.speechstorm.sky.integration.ecrm.mq.MQTranspor t.sendSyncMessage() Preparing message, payload: &lt;?xml version="1.0" encoding="UTF-8"?&gt;


    &lt;UpdatePartyHistoryRequest xmlns="http://CRM.bskyb.com/2008/03/15/CRMGVPTelephonyService"&gt;&lt;Session&gt;&lt;Cach eType&gt;BLOB_DB&lt;/CacheType&gt;&lt;/Session&gt;&lt;PartyID&gt;11582396311490015236645& lt;/PartyID&gt;&lt;CommunicationType&gt;IVR&lt;/CommunicationType&gt;&lt;HistoryItem&gt;&lt;Offeri ngName&gt;&lt;/OfferingName&gt;&lt;ActivityName&gt;Verification&l t;/ActivityName&gt;&lt;Comments&gt;Verification Successful and criteria used was Postcode&lt;/Comments&gt;&lt;/HistoryItem&gt;&lt;/UpdatePartyHistoryRequest&gt;

    [INFO ] 2011-10-28 09:36:45,060 (http-8080-Processor23:212F0AA3-347A-4AE5-93D1-4BA88B8C1B4F:1865697110) com.speechstorm.sky.integration.ecrm.mq.MQTranspor t.sendSyncMessage() Starting Queue conenction ...

    [INFO ] 2011-10-28 09:36:45,060 (http-8080-Processor23:212F0AA3-347A-4AE5-93D1-4BA88B8C1B4F:1865697110) com.speechstorm.sky.integration.ecrm.mq.MQTranspor t.sendSyncMessage() Putting the message into 'queue://QG02GENQM1/WMQ01.0000.GEN01'

    [INFO ] 2011-10-28 09:36:45,060 (http-8080-Processor23:212F0AA3-347A-4AE5-93D1-4BA88B8C1B4F:1865697110) com.speechstorm.sky.integration.ecrm.mq.MQTranspor t.sendSyncMessage() Reading reply from 'queue://QG02GENQM1/GEN01.0000.WMQ01', JMSMessageID: ID:414d51205147303247454e514d3120204ccf9e4d0560072 0, timeout threshold: 90000ms


    &lt;GetPartyNameAddressRequest xmlns="http://CRM.bskyb.com/2008/03/15/CRMGVPTelephonyService"&gt;&lt;Session&gt;&lt;Cach eType&gt;BLOB_DB&lt;/CacheType&gt;&lt;/Session&gt;&lt;PartyID&gt;11582396311490015236645& lt;/PartyID&gt;&lt;/GetPartyNameAddressRequest&gt;] was [&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;NS1:GetPartyNameAddressResponse xmlns:NS1="http://CRM.bskyb.com/2008/03/15/CRMGVPTelephonyService"&gt;&lt;NS1:Session&gt;&lt; NS1:ID&gt;NCI73351009&lt;/NS1:ID&gt;&lt;NS1:CacheType&gt;BLOB_DB&lt;/NS1:CacheType&gt;&lt;/NS1:Session&gt;&lt;NS1:ResultCode&gt;Success&lt;/NS1:ResultCode&gt;&lt;NS1:Customer&gt;&lt;NS1:Part yID&gt;11582396311490015236645&lt;/NS1:PartyID&gt;&lt;NS1:Title&gt;MISS&lt;/NS1:Title&gt;&lt;NS1:Forename&gt;Geisha&lt;/NS1:Forename&gt;&lt;NS1:Surname&gt;Hussmann&lt;/NS1:Surname&gt;&lt;NS1ateOfBirth&gt;01011980&lt;/NS1ateOfBirth&gt;&lt;NS1:Priority&gt;STANDARD&lt;/NS1:Priority&gt;&lt;/NS1:Customer&gt;&lt;NS1:Address&gt;&lt;NS1:ID&gt;1 1582396312530015236649&lt;/NS1:ID&gt;&lt;NS1:AddressIndicator&gt;PRIMARY&lt;/NS1:AddressIndicator&gt;&lt;NS1:Validated&gt;true& lt;/NS1:Validated&gt;&lt;NS1:HouseNumber&gt;1&lt;/NS1:HouseNumber&gt;&lt;NS1:Street&gt;The Paddock&lt;/NS1:Street&gt;&lt;NS1:Town&gt;NORTH BERWICK&lt;/NS1:Town&gt;&lt;NS1:County&gt;East Lothian&lt;/NS1:County&gt;&lt;NS1:CountryCode&gt;GBR&lt;/NS1:CountryCode&gt;&lt;NS1:PostCode&gt;EH395AD&lt;/NS1:PostCode&gt;&lt;/NS1:Address&gt;&lt;/NS1:GetPartyNameAddressResponse&gt;]



    [DEBUG] 2011-10-28 09:36:45,638 (http-8080-Processor23:212F0AA3-347A-4AE5-93D1-4BA88B8C1B4F:1865697110) com.speechstorm.sky.integration.ecrm.mq.MQTranspor t.sendSyncMessage() Raw message reply for [&lt;?xml version="1.0" encoding="UTF-8"?&gt;


    &lt;UpdatePartyHistoryRequest xmlns="http://CRM.bskyb.com/2008/03/15/CRMGVPTelephonyService"&gt;&lt;Session&gt;&lt;Cach eType&gt;BLOB_DB&lt;/CacheType&gt;&lt;/Session&gt;&lt;PartyID&gt;11582396311490015236645& lt;/PartyID&gt;&lt;CommunicationType&gt;IVR&lt;/CommunicationType&gt;&lt;HistoryItem&gt;&lt;Offeri ngName&gt;&lt;/OfferingName&gt;&lt;ActivityName&gt;Verification&l t;/ActivityName&gt;&lt;Comments&gt;Verification Successful and criteria used was Postcode&lt;/Comments&gt;&lt;/HistoryItem&gt;&lt;/UpdatePartyHistoryRequest&gt;] was [&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;NS1:UpdatePartyHistoryResponse xmlns:NS1="http://CRM.bskyb.com/2008/03/15/CRMGVPTelephonyService"&gt;&lt;NS1:Session&gt;&lt; NS1:ID&gt;NCI73351010&lt;/NS1:ID&gt;&lt;NS1:CacheType&gt;BLOB_DB&lt;/NS1:CacheType&gt;&lt;/NS1:Session&gt;&lt;NS1:ReturnCode&gt;HistoryUpdate d&lt;/NS1:ReturnCode&gt;&lt;/NS1:UpdatePartyHistoryResponse&gt;]


    [DEBUG] 2011-10-28 09:36:46,685 (http-8080-Processor23:212F0AA3-347A-4AE5-93D1-4BA88B8C1B4F:1865697110) org.apache.jsp.HandleGVPHangup_jsp.Main() Call result was 'success'

    [DEBUG] 2011-10-28 09:36:46,685 (http-8080-Processor23:212F0AA3-347A-4AE5-93D1-4BA88B8C1B4F:1865697110) org.apache.jsp.HandleGVPHangup_jsp.Main() Not writing call to DB.</font>

    [DEBUG] 2011-10-28 09:50:45,357 (AWT-EventQueue-0:AF5A1B6B-4EAB-4B24-8A72-DD52D860D93E:2072070248) com.speechstorm.integration.IntelliConfig.updateCh eckSum() No Checksum Changes. Retaining Configuration File.

    [DEBUG] 2011-10-28 10:05:45,357 (AWT-EventQueue-0:AF5A1B6B-4EAB-4B24-8A72-DD52D860D93E:2072070248) com.speechstorm.integration.IntelliConfig.updateCh eckSum() No Checksum Changes. Retaining Configuration File.

    [DEBUG] 2011-10-28 10:20:45,357 (AWT-EventQueue-0:AF5A1B6B-4EAB-4B24-8A72-DD52D860D93E:2072070248) com.speechstorm.integration.IntelliConfig.updateCh eckSum() No Checksum Changes. Retaining Configuration File.







    In QTP I use the following code (which extract lines with time/date only, therefore I miss lines with no date/time)

    <font color="green"> Const ForReading = 1

    Set objRegEx = CreateObject("VBScript.RegExp")
    objRegEx.Pattern ="^.*\b(2011-10-28 09:35|2011-10-28 09:36)\b.*$"

    file_location = "C:\User\output.txt"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.CreateTextFile(file_location, True)

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("C:\log\results.txt", ForReading)

    Do Until objFile.AtEndOfStream
    strSearchString = objFile.ReadLine
    Set colMatches = objRegEx.Execute(strSearchString)
    If colMatches.Count &gt; 0 Then
    For Each strMatch in colMatches
    file.write(strMatch&amp;vbCrLf&amp;vbCrLf)
    Next
    End If
    Loop

    objFile.Close </font>




    How can I extract lines of the log in the same way it is highlighted above?

  2. #2
    Junior Member
    Join Date
    Nov 2008
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Extracting lines with regular expression

    One solution would be "extract everything between first line containing 2011-10-28 09:35 and last line containing 2011-10-28 09:36" but I have no idea what code to develop.


    Does anyone know?

  3. #3
    Member
    Join Date
    Feb 2007
    Posts
    347
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Extracting lines with regular expression

    Please clarify exactly what kind of data pattern you want to extract?

    Do you want to extract every line with or without date,even so then why are you not highlighting certain lines(as in red color)?

    Please provide us your exact pattern requirement to give you concrete solution..
    Vishal Aggarwal
    Test Architect
    http://testocean.blogspot.in/

  4. #4
    Junior Member
    Join Date
    Nov 2008
    Posts
    28
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Extracting lines with regular expression

    Hi Vishul,

    In the log posted above, I would like to extract the lines highlighted in red, in that exact order. I thought about a regular expression first (it would work if I had dates in every line) but as mentioned there are some lines without dates (i.e. the one starting with "GetPartyNameAddressRequest")
    Perhaps it is better to define a "start string" and a "end string" (both with dates) and looping the in-string content line by line between those two delimiters, but I don't know how to.In the log I have added returns between lines to make it easier to view.

    Any help would be great...


  5. #5
    Apprentice
    Join Date
    Jan 2006
    Location
    Navi Mumbai, India
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Extracting lines with regular expression

    Please try the following:

    *****************************************

    Const ForReading = 1

    Set objRegEx = CreateObject("VBScript.RegExp")
    objRegEx.Pattern ="^.*\b(2011-10-28 09:35|2011-10-28 09:36)\b.*$"

    file_location = "C:\User\output.txt"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set file = fso.CreateTextFile(file_location, True)

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("C:\log\results.txt", ForReading)

    Do Until objFile.AtEndOfStream
    strSearchString = objFile.ReadLine
    LineN = LineN + 1
    Set colMatches = objRegEx.Execute(strSearchString)
    If colMatches.Count &gt; 0 Then
    LastLine = LineN
    If MatchCount = 0 and LastLine&gt;0 Then
    FirstLine = LineN
    MatchCount = MatchCount+1
    End If
    End If
    Loop
    objFile.Close

    Set objFile = objFSO.OpenTextFile("C:\log\results.txt", ForReading)

    Do Until objFile.AtEndOfStream
    strSearchString = objFile.ReadLine
    i = i+1
    If i &gt;= FirstLine and i &lt;= LastLine+1 Then
    file.write(strSearchString&amp;vbCrLf)
    End If

    objFile.Close

    ***********************************************
    Thanks & Regards,
    Sidharth

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:27 PM.

Copyright BetaSoft Inc.