Ejemplo n.º 1
0
    /// <summary>
    /// Auxiliar method for threading.
    /// Parses the CSV file into an in-memory database (DataTable).
    /// </summary>
    void LoadDataTable()
    {
        parsingCompleted = false;

        if (timeCtrl != null)
        {
            timeCtrl.ShowLoadingIcon(true);
        }

        Stopwatch diagnosticTime = new Stopwatch();

        diagnosticTime.Start();

        try
        {
            UnityEngine.Debug.Log("Parsing...");

            vVisParser = new GenericParserAdapter(csvFilePath);
            vVisParser.FirstRowHasHeader = true;

            vVisDataTable.Clear();
            vVisDataTable = vVisParser.GetDataTable();

            UnityEngine.Debug.Log("Parsing process completed");
        }
        catch (System.Exception e)
        {
            UnityEngine.Debug.LogError("Error parsing the CSV file: " + e.Message);
        }
        finally
        {
            vVisParser.Close();
            diagnosticTime.Stop();
            UnityEngine.Debug.Log("Time needed to parse (s): " + diagnosticTime.Elapsed.TotalSeconds);

            if (timeCtrl != null)
            {
                timeCtrl.ShowLoadingIcon(false);
            }

            parsingCompleted = true;
        }
    }