Results 1 to 4 of 4

Thread: Extracting Selected Data from a txt file

  1. #1
    Join Date
    Aug 2010
    Posts
    2

    Extracting Selected Data from a txt file

    Hi All,

    I am trying to extract selected data from a text file:

    V 2010-08-18:15:37:00.686 GMT Daylight Time Time Zone: GMT + 1:00 - - PPES 1 7.4
    G 2010-08-18:15:37:00.686 GMT Daylight Time Time Zone: GMT + 1:00 - - PPES FGN 1620
    I 2010-08-18:15:37:00.686 GMT Daylight Time Time Zone: GMT + 1:00 - - PPES SRV cognos2:8010
    I 2010-08-18:15:37:00.686 GMT Daylight Time Time Zone: GMT + 1:00 7zjZjneGw0WpmSUqCc_21136l7cgbvrh 104b PPRQ REQINFO PWQ,"/Cube 023 (Sector Sales and Margin)","D:/Business Reporting/Cubes/Live Cubes/Cube 023 (Sector Sales and Margin).mdc","",""
    I 2010-08-18:15:37:01.218 GMT Daylight Time Time Zone: GMT + 1:00 7zjZjneGw0WpmSUqCc_21136l7cgbvrh 104b PPDS USR BMan
    I want to extract the user, date and cube name from this file, does anyone know i can do this?

    Thanks

    Sid:

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Re: Extracting Selected Data from a txt file

    How will you be extracting the data from the file? Using VB or something else? If you want it with the help of VBA then simply create a code which looks like this:

    Code:
    Option Explicit
    Public iR, jZ As Long, theRows
    Sub getFields()
        theRows = Application.CountA(ActiveSheet.Range("A:A"))
        For jZ = 2 To theRows
            Open Cells(jZ, 6) For Input Access Read As #6 
                Line Input #6, xR  
                    If Left(iR, 7) = "Title: " Then
                        Cells(jZ, 2) = Right(iR, Len(iR) - 7)
                    End If
                    If Left(iR, 8) = "Author: " Then
                        Cells(jZ, 4) = Right(iR, Len(iR) - 8)
                    End If
                    If Left(iR, 9) = "Subject: " Then
                        Cells(jZ, 3) = Right(iR, Len(iR) - 9)
                    End If
            Loop
            Close #6  
        Next    
    End Sub

  3. #3
    Join Date
    Aug 2010
    Posts
    2

    Re: Extracting Selected Data from a txt file

    Hi,

    Thanks for your reply, but the code you have supplied is to work with an excel worksheet?

    Sid

  4. #4
    Join Date
    Feb 2010
    Posts
    118

    Re: Extracting Selected Data from a txt file

    To read a text file, look at the class java.io.BufferedReader with the method readLine ( ) . Then to parse your input file , it depends on how the data are structured : csv , fixed length data. xls file for output, there are libraries that enable the create ( POI jakarta amongst others).

Similar Threads

  1. Replies: 6
    Last Post: 26-02-2011, 10:26 AM
  2. Extracting data from XML file
    By Remedy in forum Software Development
    Replies: 4
    Last Post: 08-03-2010, 10:58 PM
  3. Retrieve selected Data From a Table
    By samualres in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 10:04 AM
  4. Getting data from a selected row in gridview in VB.Net
    By Booth in forum Software Development
    Replies: 2
    Last Post: 15-01-2009, 10:39 PM
  5. Extracting Data and Importing to Excel
    By jaykf014 in forum Software Development
    Replies: 3
    Last Post: 08-10-2008, 06:58 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,579,996.18140 seconds with 17 queries