I'm having trouble creating the 2-d array "smartdata" from my CSV file data "smart eye data.csv". I keep getting errors stating "Object reference not set to an instance of an object".
I know that 2 for loops will be necessary to create the outer and inner dimensions of the matrix, but still haven't got this to work. The CSV data is just a spreadsheet of numbers. Any help would be greatly appreciated. Thanks
using (StreamReader oStreamReader = new StreamReader(File.OpenRead("Smart Eye data.csv")))
{
sFileContents = oStreamReader.ReadToEnd();
}
string[][] smartdata = new string[1000][];
string[] sFileLines = sFileContents.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
int i = 0;
foreach(string sFileline in sFileLines)
{
string[] rowarray = sFileline.Split(",".ToCharArray(),StringSplitOptions.RemoveEmptyEntries);
for (int j = 0; j < rowarray.Length; j++)
{
smartdata[i][j] =rowarray[j]; //where the error occurs
//Debug.Log(smartdata[i][j]);
}
i = i + 1 ;
}