tags:

views:

38

answers:

1

I'm trying to get this resolved in .NET 2.0 and unfortunately that is not negotiable.

I am reading in a csv file with columns of data that 'should' correspond to a List of tickers in IdentA with some modifications. The csv file columsn would read: A_MSFT,A_CSCO,_A_YHOO,B_MSFT,B_CSCO,B_YHOO,C_MSFT,C_CSCO,C_YHOO

IdentA[0]="MSFT"
IdentA[1]="CSCO"
IdentA[2]="YHOO"

The AssetsA array is populated with the csv data
AssetsA[0]=0
AssetsA[1]=1.1
AssetsA[2]=0
AssetsA[3]=2
AssetsA[4]=3.2
AssetsA[5]=12
AssetsA[6]=54
AssetsA[7]=13
AssetsA[8]=0.2

The C_ columns are optional but if they exist they all need to exist. All of the suffixes must match the values in IdentA. The values in the csv files all need to be decimal. I'm using a group of 3 as an example, there could be any number of tickers in the IdentA array.

Its easy enough to do the first part:

for (int x = 0; x < IdentA.Count; x++)
{
    decimal.TryParse(AssetsA[x + IdentA.Count], out currentelections);
}

So that will get me the first set of values for the A_ columns but how can I get through B_ and C_ ? I can't do something as simple as IdentA.Count*2...

EDIT: IdentA gets populated when the first line of the csv is read, AssetsA is populated on subsequent lines until EOF. The original designer just always assumed that B_ and C_ would always exist and the data would just 'fall into place'. Going to look at what it would take to redesign it :(

A: 

use 2d arrays to go through two arrays like so

for(int i = 0; i <= twoDeeArr[0].Count-1; i++)
{
     for(int j = 0; j <= twoDeeArr.Count-1; j++)
     {
          decimal.TryParse((decimal)twoDeeArr[i][j], out currentElections);
     }
}
Ayo