Results 1 to 3 of 3

Thread: Remove Text Qualifier From CSV File

  1. #1

    Thread Starter
    Member Suidae's Avatar
    Join Date
    Nov 2001
    Posts
    52

    Remove Text Qualifier From CSV File

    How would I go about stripping out the text qualifier from a CSV file?

    " is the qualifier.

    This is what I have and it works as long as there is no qualifier

    Code:
        Dim arrData() As String
        Dim s As Variant
        Dim i As Integer
    
            Open "Filename" For Input As #1
            
            Do While Not EOF(1)
            rs.AddNew
            Line Input #1, s
            
            arrData = Split(s, ",")
          
            For i = 0 To UBound(arrData)
                'Debug.Print arrData(i)
                rs!TRANS_ID = arrData(0)
                rs!CO = arrData(1)
                rs!FACid = arrData(2)

    Thanks for any and all help...
    I'm a misanthropic philanthropist!
    Frog, the only white meat...

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,526
    If each line (record) has the same number of fields, you could do this:

    VB Code:
    1. For intTemp1 = 1 To intFields
    2.     Input #1, strField(intTemp1)
    3. Next intTemp1

    Otherwise, you will need to write a function that looks for a quote at the beginning of the record, and if it finds one, looks for the next quote and strips off the field, removes the quotes and comma, and then repeats until the record is empty.

  3. #3
    Member Evil_Ryu's Avatar
    Join Date
    Mar 2001
    Location
    In the Shotokan Dojo...
    Posts
    58

    Use Replace()

    You may use the Replace function...

    ex.

    strText ="Hola..."

    strText=Replace(strText,".","")

    this give a result like this:

    "Hola"

    the first parameter is the string to process, the second is the character to find, and the last parameter is the character to put in change of the second parameter...

    I hope this would help you...

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