+ Reply to Thread
Results 1 to 5 of 5

Import Pipe Delimited File, Parse out certian Fields, create new f

  1. #1
    StarBoy2000
    Guest

    Import Pipe Delimited File, Parse out certian Fields, create new f

    In Excel 2000, how do I take a pipe delimited file, strip out column(field)
    6, 10, 11, 21. Then take that data, create a new pipe delimited file, and put
    the stripped 4 fields in columns 4,5,6,7 of a 15 column(field) new pipe
    delimited file? I want to do this automatically on a file that contains
    1000+ records.

  2. #2
    JE McGimpsey
    Guest

    Re: Import Pipe Delimited File, Parse out certian Fields, create new f

    What goes in columns 1-3 and 8-15 of the new file?


    In article <[email protected]>,
    "StarBoy2000" <[email protected]> wrote:

    > In Excel 2000, how do I take a pipe delimited file, strip out column(field)
    > 6, 10, 11, 21. Then take that data, create a new pipe delimited file, and put
    > the stripped 4 fields in columns 4,5,6,7 of a 15 column(field) new pipe
    > delimited file? I want to do this automatically on a file that contains
    > 1000+ records.


  3. #3
    StarBoy2000
    Guest

    Re: Import Pipe Delimited File, Parse out certian Fields, create n

    Those columns will be hardcoded with text or left blank (null). The system
    I'm sending the new file to has to receive a 15 column (piped) file.

    "JE McGimpsey" wrote:

    > What goes in columns 1-3 and 8-15 of the new file?
    >
    >
    > In article <[email protected]>,
    > "StarBoy2000" <[email protected]> wrote:
    >
    > > In Excel 2000, how do I take a pipe delimited file, strip out column(field)
    > > 6, 10, 11, 21. Then take that data, create a new pipe delimited file, and put
    > > the stripped 4 fields in columns 4,5,6,7 of a 15 column(field) new pipe
    > > delimited file? I want to do this automatically on a file that contains
    > > 1000+ records.

    >


  4. #4
    JE McGimpsey
    Guest

    Re: Import Pipe Delimited File, Parse out certian Fields, create n

    One way:

    Public Sub PipeFileTransform()
    Const sDELIMITER As String = "|"
    Dim vArr As Variant
    Dim nFileIn As Long
    Dim nFileOut As Long
    Dim sPre As String
    Dim sPost As String
    Dim sInput As String
    Dim sOutput As String

    sPre = String(3, sDELIMITER)
    sPost = String(8, sDELIMITER)

    nFileIn = FreeFile
    Open "Test1.txt" For Input As #nFileIn
    nFileOut = FreeFile
    Open "Test2.txt" For Output As #nFileOut
    Do While Not EOF(1)
    Line Input #1, sInput
    vArr = Split(sInput, "|")
    sOutput = sPre & vArr(5) & sDELIMITER & vArr(9) & _
    sDELIMITER & vArr(10) & sDELIMITER & _
    vArr(20) & sPost
    Print #2, sOutput
    Loop
    Close #nFileIn
    Close #nFileOut
    End Sub

    Adjust sPre and sPost as desired. Note that Split() is a VBA6 function.
    If you need this to work with WinXL97 or MacXL, you'll need to roll your
    own Split function.



    In article <[email protected]>,
    "StarBoy2000" <[email protected]> wrote:

    > Those columns will be hardcoded with text or left blank (null). The system
    > I'm sending the new file to has to receive a 15 column (piped) file.


  5. #5
    JE McGimpsey
    Guest

    Re: Import Pipe Delimited File, Parse out certian Fields, create n

    It doesn't make any difference in this case, but for foolish
    consistency, the line below should have been:

    vArr = Split(sInput, sDELIMITER)



    In article <[email protected]>,
    JE McGimpsey <[email protected]> wrote:


    > vArr = Split(sInput, "|")


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1