CSV file into Dynamic Table RRS feed

  • Question

  • Greetings all..

    I'm pretty new to tables/files and I'm simply trying to read a .CSV file, which I found how to read each column and field using the standard example which messageboxes each column then each field. The problem is I don't understand tables that well, so basically I want to import the entire .CSV file into a table dynamically and I can't seem to figure it out. I searched the forums but they all seem to be way beyond where I'm at now.

    Like I said I'm able to read each row/column from the .CSV, it's getting the .CSV's contents which are now read into a table dynamically is what I can't figure out. Any help would be appreciated, thanks a lot!


    Saturday, April 14, 2007 12:44 AM


  • StyVB,


    Here is a code sample for a transformation script to illustrate the idea.  The Row.Line is the input column that contains an entire line of a text file.  This line is taken and split into an array by the comma delimiter.  The first time we see the line, it is a header with column names.  A boolean flag is used to detect the header condition and we save the column names in a variable.  For every subsequent row, we iterate through the column names and match them to an output column that has been defined for the script, assigning the value parsed from the file into the correct column.  Using this method, the order of the columns in the text file is irrelevant.


    Code Snippet

    Dim Line As String = Row.Line

    Dim LineTokens As String() = Line.Split(","c)


    If IsHeader Then

        HeaderColumns = LineTokens

        IsHeader = False


    ' match input columns to output columns

        With Output0Buffer



            For i As Integer = 0 To HeaderColumns.Length - 1

                Select Case HeaderColumns(i)

                    Case "Time"

                        .Time = LineTokens(i)

                    Case "Probe1"

                        .Probe1 = LineTokens(i)

                    Case "Probe2"

                        .Probe2 = LineTokens(i)

                    Case "Probe3"

                        .Probe3 = LineTokens(i)

                    Case "Probe4"

                        .Probe4 = LineTokens(i)

                End Select



        End With

    End If


    For further information, please take a look at the discussion in MSDN forum:






    Thursday, April 19, 2007 5:02 AM