Hi, @Havooma ,
You can refer to the following code to read the csv file into the datatable.
Use DataTable's BeginLoadData and EndLoadData methods to implement bulk inserts of data, reducing the overhead of insert operations.
Dim filePath As String = "test.csv"
Dim dt As New DataTable()
Using sr As New StreamReader(filePath)
Dim headers As String() = sr.ReadLine().Split(",")
For Each header As String In headers
dt.Columns.Add(header)
Next
While Not sr.EndOfStream
Dim rows As String() = sr.ReadLine().Split(",")
Dim dr As DataRow = dt.NewRow()
For i As Integer = 0 To headers.Length - 1
dr(i) = rows(i)
Next
dt.Rows.Add(dr)
End While
End Using
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.