1
I am reading a csv file by a Console Application, and up to this point is returning me correctly.
Now I’m having trouble understanding how to include each field in a Bank column.
This is the code I have so far.
Public Function LerCsvConfrec()
Dim sb As New StringBuilder
Dim ds As New DataSet
Dim dtConfrec As New DataTable
Dim maquinaProducao As String = "PRODUCAO"
Dim pastaOrigem As String = ""
Dim pastaDestino As String = ""
If Environment.MachineName = "PRODUCAO" Then
'PRODUÇÃO
pastaOrigem = "C:\KAWASAKI\FTP\SUPPORTE-UBERLANDIA\INBOUND\CONFREC\"
pastaDestino = "C:\KAWASAKI\FTP\SUPPORTE-UBERLANDIA\INBOUND\CONFREC\Lidos\"
Else
'TESTE
pastaOrigem = "C:\temp\Confrec\"
pastaDestino = "C:\temp\Confrec\Lidos\"
End If
'Busca arquivos .csv na Pasta de Origem
Dim dirCsv As String() = Directory.GetFiles(pastaOrigem, "*.csv")
Try
For Each csvFile In dirCsv
'Lê o conteúdo de cada arquivo
Dim arqCsv As String = File.ReadAllText(csvFile)
For Each linha As String In arqCsv.Split(vbCrLf)
'Verifica se não está vazio
If Not String.IsNullOrEmpty(linha) Then
'Delimitador de separação usado (;)
For Each coluna As String In linha.Split(";")
Next
End If
Next
Next
Catch ex As Exception
End Try
End Function
I checked the information that returns and every time it passes by
For Each coluna As String In linha.Split(";")
Next
it returns the right information, but I was unable to enter it in the database. How can I make each column of the CSV enter the correct column of the Database ?
Oops, thanks for the answer ! But I ended up doing it another way using a string array.
– Igor