Moulijin
Moulijin

Reputation: 61

A string containing a character used for split

I am trying to split values that are separated in commas but, there is a description containing a quote but the description is in quotes. I am trying to have the code ignore that part of the description and I've googled for solution but, came up empty.

Dim rowvalue As String Dim cellvalue(20) As String

    Dim streamReader As IO.StreamReader = New IO.StreamReader("C:\Me\Manifest_0001367051.csv")
    While streamReader.Peek() <> -1
        rowvalue = streamReader.ReadLine()
        cellvalue = rowvalue.Split(","c, """,""") 'check what is ur separator
        DataGridView1.Rows.Add(cellvalue)

    End While

This is the value I am trying to break down

OL-2G,0B1,1,1,"Sn, HP Cate",T:7051; C:KI; R:A; G:N; X:N; L:; UN:; ; JP,AT,N,N,N

Upvotes: 0

Views: 94

Answers (1)

Sam Axe
Sam Axe

Reputation: 33738

Use the right tool.

String.Split is not up to the job of parsing csv.

TextFieldParser is made just for this.

Upvotes: 1

Related Questions