Home>

We have created a program to make 2D arrays from csv in Unity.
I want to execute Load_Data () and store the data in Input_Data, but it will be null.
What should I do?

Data to use

https://gist.githubusercontent.com/netj/8836201/raw/6f9306ad21398ea43cba4f7d537619d0e07d5ae3/iris.csv

Error message The
array becomes null.
Applicable source code
double [] [] Input_Data;// Input data
    void Start ()
    {
            Load_Data ();
            Debug.Log (Input_Data [0]);
    }
    public void Load_Data ()
    {
          List<string []>readCsvList = new List<string []>();
        using (StreamReader readCsvObject = new StreamReader (@ "Assets/iris.csv"))
        {
            while (! readCsvObject.EndOfStream)
            {
                var readCsvLine = readCsvObject.ReadLine ();
                readCsvList.Add (readCsvLine.Split (','));
            }
        }
        string [] [] X = readCsvList.ToArray ();
        // Read input data.
        Input_Data = new double [num_test_data] [];
        for (int i = 1;i<num_test_data;i ++)
        {
            A = "";
            Input_Data [i] = new double [num_input_nodes];
            for (int j = 0;j<num_input_nodes;j ++)
            {
                Input_Data [i] [j] = double.Parse (X [i] [j]);
                A = String.Concat (A, X [i] [j]);
                A = A + ",";
            }
           Debug.Log (Input_Data [i] [0]);
        }
        Debug.Log ("At Load_Data");
       // Input_Data becomes null.
Debug.Log (Input_Data [0] [0]);
    }
Supplemental information (FW/tool version etc.)

Unity 2018.3.7.f1