Send data from a csv to an array

0

I need to send the data that is in a csv file into an array.

I already have the importer of the csv file and the same is read only missing is to send the data to the array.

------ edited -------

Using Infragistics.Documents.Excel I already have access to the csv document, and I now need to send the data of each line to an array.

    
asked by anonymous 18.04.2018 / 11:38

2 answers

0

I was able to resolve with

Dim iRow As Integer = 1
                Dim iCol As Integer = 0

                Dim valores As String



                While oWorksheet.Rows(iRow).Cells(iCol).Value IsNot Nothing
                    valores = oWorksheet.Rows(iRow).Cells(iCol).Value
                    iCol += 1
                End While
    
18.04.2018 / 13:04
0

Try it like this:

Dim arrName() As String
Dim arrValue() As String

Using ioReader As New Microsoft.VisualBasic.FileIO.TextFieldParser("C:\test\test.csv")

    ioReader.TextFieldType = FileIO.FieldType.Delimited
    ioReader.SetDelimiters(",")

    While Not ioReader.EndOfData

        Dim arrCurrentRow As String() = ioReader.ReadFields()

        If arrName Is Nothing Then

            ReDim Preserve arrName(0)
            ReDim Preserve arrValue(0)

            arrName(0) = arrCurrentRow(0)
            arrValue(0) = arrCurrentRow(1)

        Else

            ReDim Preserve arrName(arrName.Length)
            ReDim Preserve arrValue(arrValue.Length)

            arrName((arrName.Length - 1)) = arrCurrentRow(0)
            arrValue((arrValue.Length - 1)) = arrCurrentRow(1)

        End If

    End While
    
18.04.2018 / 11:47