I have a csv file (comma delimited) that contains an unknown number of columns, and unkown number of rows, and an unknown size of string for each element. Each row has the same number of elements however. I desire to read this data into a multidimensional array or List. Because I do not now the size a List seems most appropriate, but I am having difficulties.
I can read each line into a null string and separate the entries and create a single dimensional array for each row that is read in thus;
List<string> fileLines = File.ReadAllLines(strFileName).ToList();
int entries = fileLines.Count;
string str = String.Empty;
List<string> values = new List<string>();
for (i = 0; i < entries; i++){
str = fileLines[i];//contains the value of the entire row in one string
a = str.Split(',');//broken up into its elements.
for (j=1; j<a.Length; j++){//need to eliminate the first element
c = a[j];
values.Add(c);//List that contains the elements of a that I need.
}
Now I need to assign each 'value' to a row in a multidimensional list, but I cant figure out how to do that. It seems that sring arrays and Lists do not have the same method sets. The string array method set would work, but I would have to initialize the array size, and I cant do that because I dont know it.