Exemplo n.º 1
0
        /// <summary>
        /// Reads the CSV file and load into the data frame.
        /// </summary>
        /// <param name="filepath">The filepath of the csv.</param>
        /// <param name="hasHeader">if set to <c>true</c> [will consider first row as column names].</param>
        /// <returns></returns>
        public static DataFrame2D ReadCsv(string filepath, bool hasHeader = false)
        {
            List <float> allValues   = new List <float>();
            DataFrame2D  result      = null;
            int          columnCount = 0;

            using (TextReader fileReader = File.OpenText(filepath))
            {
                var csv = new CsvReader(fileReader);
                csv.Configuration.HasHeaderRecord = true;
                float value = 0;

                while (csv.Read())
                {
                    for (int i = 0; csv.TryGetField <float>(i, out value); i++)
                    {
                        allValues.Add(value);
                    }

                    if (columnCount == 0)
                    {
                        columnCount = allValues.Count;
                    }
                }

                result = new DataFrame2D(columnCount);
                result.Load(allValues.ToArray());
            }

            return(result);
        }
Exemplo n.º 2
0
        public static DataFrame2D FromDataTable(DataTable dt)
        {
            DataFrame2D result = null;


            return(result);
        }