Hi,
I know there is a lot of information about parsing csv files on the internet, but i did not find a usable solution for my problem.
I have a CSV files with quotes. The qoutes are not always on fixed places.
for example
Name,Department,Phone number,
"Smith, John",Sales,555-123456,
Brown,"Sales, UK",+4412345678,
Johnson,sales,555-432156,
If i'm using the split method using ",", it will be a mess in my datagrid.
Any ideas to solve my problem?
A part of my code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fName As String = "C:\test.csv"
Dim TextLine As String = ""
Dim SplitLine() As String
If System.IO.File.Exists(fName) = True Then
Dim objReader As New System.IO.StreamReader(fName)
Do While objReader.Peek() <> -1
TextLine = objReader.ReadLine()
SplitLine = Split(TextLine, ",")
Me.DataGridView1.Rows.Add(SplitLine)
Loop
Else
MsgBox("File Does Not Exist")
End If
End Sub
Thanks a lot in advance
Bigsin
I know there is a lot of information about parsing csv files on the internet, but i did not find a usable solution for my problem.
I have a CSV files with quotes. The qoutes are not always on fixed places.
for example
Name,Department,Phone number,
"Smith, John",Sales,555-123456,
Brown,"Sales, UK",+4412345678,
Johnson,sales,555-432156,
If i'm using the split method using ",", it will be a mess in my datagrid.
Any ideas to solve my problem?
A part of my code
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim fName As String = "C:\test.csv"
Dim TextLine As String = ""
Dim SplitLine() As String
If System.IO.File.Exists(fName) = True Then
Dim objReader As New System.IO.StreamReader(fName)
Do While objReader.Peek() <> -1
TextLine = objReader.ReadLine()
SplitLine = Split(TextLine, ",")
Me.DataGridView1.Rows.Add(SplitLine)
Loop
Else
MsgBox("File Does Not Exist")
End If
End Sub
Thanks a lot in advance
Bigsin