예제 #1
0
        public static GridData ImportFromFile(string path, char delim = ';')
        {
            double[,] data;
            try
            {
                var res = File.ReadAllLines(path).Select(
                    l => l.Split(delim).Select(
                        w => double.Parse(w.Trim())
                        ).ToArray()
                    ).ToArray();
                int rows    = res.First().Length;
                int columns = res.Length;

                data = new double[rows, columns];

                for (int i = 0; i < rows; i++)
                {
                    for (int j = 0; j < columns; j++)
                    {
                        data[j, i] = res[i][j];
                    }
                }
            }
            catch (Exception e)
            {
                throw new TableLoadException("An error occured while loading table.", e);
            }
            return(GridData.FromArray(data));
        }