SSIS: C# script task (create a multidimensional array)

  • Dear Forum members,

    I have a txt file which has several lines. below is a sample of those lines:

    Data sample:

    | 20171128| 20171128| 1176901|     1953|   3655228| 20171128| Quarterly      | 0|         0.06250|         0.06250|         0.04375|         0.04375| USD| 1.000|    1.00000|   336702111.0000
    | 20171128| 20171128| 1683601|     4360|   3643888| 20171128| Quarterly      | 0|         0.57000|         0.57000|         0.39900|         0.39900| USD| 1.000|    1.00000|  1477436517.0000
    | 20171128| 20171128| 2099901|    61623|   3654138| 20171128| Final          | 0|         1.30000|         1.30000|         1.30000|         1.30000| USD| 1.000|    1.00000|    41069286.0000
    | 20171128| 20171128| 2355301|    64184|   3653645| 20171128| Final          | 0|         0.45500|         0.45500|         0.34125|                | CAD| 1.000|    1.00000|   613679213.0000
    | 20171128| 20171128| 3062801|    72268|   3561489| 20171128| Final          | 0|      3350.00000|      3350.00000|      2836.94750|      2669.44750| JPY| 1.000|    1.00000|     3055087.0000
    | 20171128| 20171128| 7140301|    97562|   3554925| 20171128| Interim        | 0|      4625.00000|      4625.00000|      3916.68125|      3685.43125| JPY| 1.000|    1.00000|     2049780.0000

    Each line has several attributes delimited by "|"

    using an C# task,  what is the best way to create an array that will store each line with its attributes?

    Can you please help me with a code sample?

    Thank you

  • river1 - Tuesday, December 19, 2017 6:17 AM

    Dear Forum members,

    I have a txt file which has several lines. below is a sample of those lines:

    Data sample:

    | 20171128| 20171128| 1176901|     1953|   3655228| 20171128| Quarterly      | 0|         0.06250|         0.06250|         0.04375|         0.04375| USD| 1.000|    1.00000|   336702111.0000
    | 20171128| 20171128| 1683601|     4360|   3643888| 20171128| Quarterly      | 0|         0.57000|         0.57000|         0.39900|         0.39900| USD| 1.000|    1.00000|  1477436517.0000
    | 20171128| 20171128| 2099901|    61623|   3654138| 20171128| Final          | 0|         1.30000|         1.30000|         1.30000|         1.30000| USD| 1.000|    1.00000|    41069286.0000
    | 20171128| 20171128| 2355301|    64184|   3653645| 20171128| Final          | 0|         0.45500|         0.45500|         0.34125|                | CAD| 1.000|    1.00000|   613679213.0000
    | 20171128| 20171128| 3062801|    72268|   3561489| 20171128| Final          | 0|      3350.00000|      3350.00000|      2836.94750|      2669.44750| JPY| 1.000|    1.00000|     3055087.0000
    | 20171128| 20171128| 7140301|    97562|   3554925| 20171128| Interim        | 0|      4625.00000|      4625.00000|      3916.68125|      3685.43125| JPY| 1.000|    1.00000|     2049780.0000

    Each line has several attributes delimited by "|"

    using an C# task,  what is the best way to create an array that will store each line with its attributes?

    Can you please help me with a code sample?

    Thank you

    Please describe why you want to do this in C#, rather than a straightforward data flow.
    What are you going to do with this array, once it is populated?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Phil Parkin - Tuesday, December 19, 2017 6:30 AM

    river1 - Tuesday, December 19, 2017 6:17 AM

    Dear Forum members,

    I have a txt file which has several lines. below is a sample of those lines:

    Data sample:

    | 20171128| 20171128| 1176901|     1953|   3655228| 20171128| Quarterly      | 0|         0.06250|         0.06250|         0.04375|         0.04375| USD| 1.000|    1.00000|   336702111.0000
    | 20171128| 20171128| 1683601|     4360|   3643888| 20171128| Quarterly      | 0|         0.57000|         0.57000|         0.39900|         0.39900| USD| 1.000|    1.00000|  1477436517.0000
    | 20171128| 20171128| 2099901|    61623|   3654138| 20171128| Final          | 0|         1.30000|         1.30000|         1.30000|         1.30000| USD| 1.000|    1.00000|    41069286.0000
    | 20171128| 20171128| 2355301|    64184|   3653645| 20171128| Final          | 0|         0.45500|         0.45500|         0.34125|                | CAD| 1.000|    1.00000|   613679213.0000
    | 20171128| 20171128| 3062801|    72268|   3561489| 20171128| Final          | 0|      3350.00000|      3350.00000|      2836.94750|      2669.44750| JPY| 1.000|    1.00000|     3055087.0000
    | 20171128| 20171128| 7140301|    97562|   3554925| 20171128| Interim        | 0|      4625.00000|      4625.00000|      3916.68125|      3685.43125| JPY| 1.000|    1.00000|     2049780.0000

    Each line has several attributes delimited by "|"

    using an C# task,  what is the best way to create an array that will store each line with its attributes?

    Can you please help me with a code sample?

    Thank you

    Please describe why you want to do this in C#, rather than a straightforward data flow.
    What are you going to do with this array, once it is populated?

    This is a very complex txt file. I am creating a c# to devide it into several excel files. So far I was already able to create a normal array which olds the columns. Now I need one that olds the records of those columns.   Instead of a multidimensional array, I can also have a normal array, like starting with # and then have the records and then another # before a new line (new records begin again).    I think I will first have to split the line using a split function and then, line by line populate the array starting and ending with *

  • river1 - Tuesday, December 19, 2017 6:35 AM

    Phil Parkin - Tuesday, December 19, 2017 6:30 AM

    Please describe why you want to do this in C#, rather than a straightforward data flow.
    What are you going to do with this array, once it is populated?

    This is a very complex txt file. I am creating a c# to devide it into several excel files. So far I was already able to create a normal array which olds the columns. Now I need one that olds the records of those columns.   Instead of a multidimensional array, I can also have a normal array, like starting with # and then have the records and then another # before a new line (new records begin again).    I think I will first have to split the line using a split function and then, line by line populate the array starting and ending with *

    OK, are you using a script component with multiple outputs (one for each file type) to do this? If yes, all you need to do, for each row, is as follows:

    1) Determine file type
    2) Split the row into its elements
    3) Assign the elements to a new output row, with the output corresponding to the file type required.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply