Results 1 to 7 of 7
  1. #1
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480

    Text Parsing and Split Function

    Hello everyone. I have a report that runs nightly, it is saving text files successfully. I am trying to clean up these reports with Split functions and parsing... I have read about this on the MSDN site...Here is what I am trying to do...

    These reports contain raw data.. and the information I need inside of it.... Wanting every line begininng with a "< " to be removed and then the extra spaces removed. I know this can be done thru excel using macros but I am hoping the same can be accomplished here...
    Code:
    <0d:CR>                      ( 3:31) ==> ( 3: 1)
    <0c:FF>                      ( 4: 1) ==> 
    <0d:CR>                      ( 4: 1) ==> ( 4: 1)
    <0a:LF>                      ( 4: 1) ==> ( 5: 1)
    <0d:CR>                      ( 5: 1) ==> ( 5: 1)
    <0a:LF>                      ( 5: 1) ==> ( 6: 1)
              Groups with Communication Problems  04/12/2012  09:01
    <0d:CR>                      ( 6:73) ==> ( 6: 1)
    <0a:LF>                      ( 6: 1) ==> ( 7: 1)
    <0d:CR>                      ( 7: 1) ==> ( 7: 1)
    <0a:LF>                      ( 7: 1) ==> ( 8: 1)
    <0d:CR>                      ( 8: 1) ==> ( 8: 1)
    <0a:LF>                      ( 8: 1) ==> ( 9: 1)
    Autodial       Phone #             Next Time Trigger   Total/Finals/Reprints
    <0d:CR>                      ( 9:77) ==> ( 9: 1)
    <0a:LF>                      ( 9: 1) ==> (10: 1)
    <0d:CR>                      (10: 1) ==> (10: 1)
    <0a:LF>                      (10: 1) ==> (11: 1)
    <0d:CR>                      (11: 1) ==> (11: 1)
    <0a:LF>                      (11: 1) ==> (12: 1)
      DOUGC        915xxxxxxx     09:55                    1/1/0
    <0d:CR>                      (12:66) ==> (12: 1)
    <0a:LF>                      (12: 1) ==> (13: 1)
      GASTR        915xxxxxxx       09:41                    6/5/0
    <0d:CR>                      (13:66) ==> (13: 1)
    <0a:LF>                      (13: 1) ==> (14: 1)
      LUUMD        913xxxxxxx      09:12                    1/1/0
    <0d:CR>                      (14:66) ==> (14: 1)
    <0a:LF>                      (14: 1) ==> (15: 1)
      PHILM        915xxxxxxx       09:12                    6/5/0
    <0d:CR>                      (15:66) ==> (15: 1)
    <0a:LF>                      (15: 1) ==> (16: 1)
      QDXAPHSP     919xxxxxxx     09:04                    9/7/0
    <0d:CR>                      (16:66) ==> (16: 1)
    <0a:LF>                      (16: 1) ==> (17: 1)
      SON          913xxxxxxx       08:57                    8/5/0
    <0d:CR>                      (17:66) ==> (17: 1)
    <0a:LF>                      (17: 1) ==> (18: 1)
    <0d:CR>                      (18: 1) ==> (18: 1)
    <0a:LF>                      (18: 1) ==> (19: 1)
    <0d:CR>                      (19: 1) ==> (19: 1)
    <0a:LF>                      (19: 1) ==> (20: 1)
              ********* Autodials queued to report STAT *********
    <0d:CR>                      (20:62) ==> (20: 1)
    <0a:LF>                      (20: 1) ==> (21: 1)
    <0d:CR>                      (21: 1) ==> (21: 1)
    <0a:LF>                      (21: 1) ==> (22: 1)
    So these text files are saved locally on my PC. Is there a way to have the VBA parse these either after they are created, or While they are being formatted?? With the help of people here I have this as my formatting technique..

    Name "C:\Program Files\LIFT Ericom Software\PowerTerm\trace.log" As "C:\TroubleList\Florida\Florida" & Format(Now(), "yyyymmddhhmm") & ".txt"

    MSDN site = http://msdn.microsoft.com/en-us/libr...ffice.10).aspx

    What I want the final report to look like...

    Code:
       Groups with Communication Problems  04/12/2012  09:01
    Autodial       Phone #             Next Time Trigger   Total/Finals/Reprints
     DOUGC        915xxxxxxx     09:55                    1/1/0
     GASTR        915xxxxxxx       09:41                    6/5/0
     LUUMD        913xxxxxxx      09:12                    1/1/0
     PHILM        915xxxxxxx       09:12                    6/5/0
     QDXAPHSP     919xxxxxxx     09:04                    9/7/0
     SON          913xxxxxxx       08:57                    8/5/0
    As always I appreciate any assistance, I hope I provided enough information.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You have gotten as far as extracting this data from some program (PowerTerm?) and saving as a text file?

    VBA code can read the text file and selectively import data to a table. Use that table as RecordSource for a report.

    Text import is common topic. Here is one recent thread https://www.accessforums.net/showthr...ccess-database

    And an oldie http://www.dbforums.com/6274796-post24.html

    Advise no spaces, special characters, punctuation (underscore is exception) in any names, nor reserved words as names.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Very cool, So I am going to start digging into those links. Yea Powerterm is an old unix emulator thing... also known as a nightmare.

  4. #4
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Is there a way to do this using regular expression?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What do you mean by 'regular expression'? Regular as opposed to what?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    MarvinP is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Seattle, WA
    Posts
    2
    Hi,

    It looks to me you want all records that don't start with the "<" character.
    After you import the text you can do a query using a filter of -Not Like "<*"-
    Then the only records left will be the ones you want.

  7. #7
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Okay, I cannot take credit for this.. We have a ninja here and this is what he came up with..

    Code:
    Sub RegEx()
    
    
      Dim oFS As FileSystemObject
      Dim oText As TextStream
      Dim strRawData, strFormattedData As String
      Dim oRegEx As RegExp
      Dim oMatches As MatchCollection
      Dim oMatch As Match
    
    
      Set oRegEx = New RegExp
      oRegEx.Global = True
      oRegEx.Pattern = "\s[A-Z0-9\s]*\s*\d{7,12}\s*[^(]\d\d:\d\d[^)]\s*\d*/\d*/\d*\s"
      ' Other ID    \s[A-Z0-9]\s*
      ' Invoice #   \d{10,}\s*
      ' Time        [^(]\d\d:\d\d[^)]
      ' Date        \s\d*/\d*/\d*\s
        
      Set oFS = New FileSystemObject
      Set oText = oFS.OpenTextFile("C:\Program Files\LIFT Ericom Software\PowerTerm\trace.log", ForReading)
        
      strRawData = oText.ReadAll
        
      oText.Close
      Set oText = Nothing
      
      Set oMatches = oRegEx.Execute(strRawData)
    
    
      Set oText = oFS.OpenTextFile("C:\TroubleList\Atlanta\skb " & Format(Date, "mm-dd-yyyy") & ".txt", ForWriting, True)
      
      For Each oMatch In oMatches
        strFormattedData = Replace(oMatch, vbCr, "")
        oText.WriteLine Replace(strFormattedData, vbLf, "")
      Next oMatch
      
      oText.Close
      Set oText = Nothing
      
      Set oRegEx = Nothing
      Set oMatches = Nothing
      
      Set oFS = Nothing
    
    
      MsgBox "New Parsed File Created"
    End Sub
    We were able to test this here http://www.gskinner.com/RegExr/, this will select only the text we want, format the text and save it correctly.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Split() Function or something like it
    By JRS_ in forum Programming
    Replies: 15
    Last Post: 12-21-2011, 05:44 PM
  2. INNER JOIN to a split(array) function?
    By kman42 in forum Queries
    Replies: 8
    Last Post: 05-09-2011, 01:53 PM
  3. split text field
    By Zukster in forum Queries
    Replies: 4
    Last Post: 01-11-2011, 10:01 PM
  4. Split uneven text field
    By swaroop1012 in forum Queries
    Replies: 1
    Last Post: 09-11-2009, 07:42 AM
  5. Split text field into two text fields
    By Grant in forum Access
    Replies: 6
    Last Post: 01-31-2008, 05:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums