Script to convert logs columns to rows
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Script to convert logs columns to rows

  1. #1
    Join Date
    May 2009
    Posts
    2

    Exclamation Script to convert logs columns to rows

    Hi all, i have a bunch of log files that needs to be imported into a database for analysis but the logs comes in the following format:

    ****************************CDR 1****************************
    CDR_TYPE: CallRec
    callingNumber: 7590405
    calledNumber: 7500820
    answerTime: 00:03:39
    releaseTime:00:07:34
    callDuration: 235
    *************************************************************

    ****************************CDR 2****************************
    CDR_TYPE: MOSMSRecord
    serviceCentre: (91)685750004
    recordingEntity: (91)685750007
    location: (LAC: 00 0A CELLID: 75 49)
    messageReference: 31
    originationTime: 2007-09-01 00:07:34 - 0B00
    destinationNumber: (91)6857513394
    *************************************************************

    ****************************CDR 3****************************
    CDR_TYPE: CallRec
    callingNumber: 7583021
    calledNumber: 7552525
    answerTime: 00:04:39
    releaseTime: 00:07:37
    callDuration: 178
    *************************************************************

    I need a script to output data in rows insted of columns filtering only data of CDR_TYPE: CallRec

    The output should be :

    CDR_TYPE callingNumber calledNumber answerTime releaseTime callDuration
    CallRec 7590405 7500820 00:03:39 00:07:34 235
    CallRec 7583021 7552525 00:04:39 00:07:37 178
    ......


    Thanks in advance
    fono

  2. #2
    Join Date
    Jan 2006
    Location
    Chicago, IL
    Posts
    14,948

    Re: Script to convert logs columns to rows

    Well, this is a place to get help with your code. Why don't you try it yourself, and post back when you either a)have the solution, or, b) have a problem
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    May 2009
    Posts
    2

    Re: Script to convert logs columns to rows

    im newbie to VB thats why i came here

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    105

    Re: Script to convert logs columns to rows

    It seems you need everything after the first :
    I would determine the position of the first : with an instr statement and store that into a variable
    Than take the right$ of the line with the start being the position of the : and length the length of the line minus the position of the :
    Code:
    strline = "answerTime: 00:03:39 "
    pos = instr(strline,":")
    strWhatIWant = right$(strline,pos,len(strline)-pos-1)

    something like this code, but I assume you fill strline not this way but using file IO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center