コード例 #1
0
        public int count;        //cnt, total rental bikes out at the moment

        public static List <BikeData> buildFromStrArr(string[] data)
        {
            List <BikeData> result = new List <BikeData>();

            // skip header line
            for (int i = 1; i < 100; i++) //shortened for ease of view
            {
                var temp        = new BikeData();
                var currentLine = data[i].Split(',');
                temp.index      = Int32.Parse(currentLine[0]);
                temp.date       = Convert.ToDateTime(currentLine[1]);
                temp.season     = Int32.Parse(currentLine[2]);
                temp.year       = Int32.Parse(currentLine[3]);
                temp.month      = Int32.Parse(currentLine[4]);
                temp.holiday    = Int32.Parse(currentLine[5]);
                temp.hour       = Int32.Parse(currentLine[6]);
                temp.weekday    = Int32.Parse(currentLine[7]);
                temp.workingday = Int32.Parse(currentLine[8]);
                temp.weather    = Int32.Parse(currentLine[9]);
                temp.temp       = Double.Parse(currentLine[10]);
                temp.feelslike  = Double.Parse(currentLine[11]);
                temp.humidity   = Double.Parse(currentLine[12]);
                temp.windspeed  = Double.Parse(currentLine[13]);
                temp.casual     = Int32.Parse(currentLine[14]);
                temp.registered = Int32.Parse(currentLine[15]);
                temp.count      = Int32.Parse(currentLine[16]);
                result.Add(temp);
            }
            return(result);
        }
コード例 #2
0
 private void LoadData()
 {
     try
     {
         var dataAsArray = File.ReadAllLines(
             HttpContext.Current.Server.MapPath(@"~/hour.csv"));
         dataset = BikeData.buildFromStrArr(dataAsArray);
     }
     catch (IOException e)
     {
         Console.WriteLine("File could not be read");
         Console.WriteLine(e.Message);
     }
 }