Results 1 to 2 of 2

Thread: pipe delimited file

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jul 2000
    Posts
    52

    pipe delimited file

    I have a pipe delimited text file. It has numerous fields in it. The fields are different size for each line of the file, so there is no way for me to tell what is in position X, and so on. I need to load in the file into a temp table I created, so I can compare the tables later on. I have a few ideas on how to do this, and would like some opinions on them as well as which functions I should look into, depending on what idea I use.

    1. Read the file character by character, separating the fields by knowing they are separated by the pipe '|' system, and also going from record to record, line to line.

    2. Throw out the idea of a temp table and just do the comparison straight from the text file to the comparison table record by record. If the data from the file needed to be loaded, I would still have the separate the fields manually.

    3. Hoping VB.NET has some kind of code where it would know about delimited files.

    4. Import the file into Access, load the temp table from the imported table. (I would like to automate the whole process however, so I consider this a last resort)

    Thanks for the help!

  2. #2
    Member
    Join Date
    Sep 2001
    Location
    Fishburn
    Posts
    45
    The method I use to read delimitted files is reading the file line by line, and then splitting the line by the delimitter.

    You can do this using the Split function. This function allows you to use any delimitter, and returns an array of sub-strings. So it doesn't matter how wide each field is.

    One thing in particular if the file is large though, the Split function included in the String class is much faster than the standard VB Split function, i.e.

    Dim A As String = "123,456,789"
    Dim B() As String = Split(A, ",")
    Dim C() As String = A.Split(",")

    The latter method will process much faster.

Posting Permissions

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



Click Here to Expand Forum to Full Width