Esempio n. 1
0
        //description of the RentDataModel attributes
        //public string TA { get; set; }
        //public string marketRentArea { get; set; }
        //public string propertyType { get; set; }
        //public string bedrooms { get; set; }
        //public float averageRentPrice { get; set; }
        public List<RentDataModel> Handler()
        {
            var reader = new StreamReader(File.OpenRead(@"~/CSV/detailed-mean-rents-total.csv"));
            List<RentDataModel> listData = new List<RentDataModel>();

            while (!reader.EndOfStream)
            {
                //init rentdata object
                var rentdata = new RentDataModel();

                //read line from csv
                var line = reader.ReadLine();
                var values = line.Split(',');

                //set values of rentdata object
                rentdata.region = values[0];
                rentdata.marketRentArea = values[1];
                rentdata.propertyType = values[2];
                rentdata.averageRentPrice = float.Parse(values.Last());

                //add rentdata object to list
                listData.Add(rentdata);
            }
            return listData;
        }
        public List<RentDataModel> Handler()
        {
            //var reader = new StreamReader(File.OpenRead("~/CSV/detailed-mean-rents-total.csv"));
            List<RentDataModel> listData = new List<RentDataModel>();

            //wile (!reader.EndOfStream)

            String csvf = new csvFile().csvFileData;
            String[] csvArray = csvf.Split('~');

            foreach (string line in csvArray)
            {
                //init rentdata object
                var rentdata = new RentDataModel();

                //read line from csv
                var values = line.Split(',');

                //set values of rentdata object
                rentdata.region = values[0];
                rentdata.marketRentArea = values[1];
                rentdata.propertyType = values[2];
                rentdata.averageRentPrice = float.Parse(values.Last());

                //add rentdata object to list
                listData.Add(rentdata);
                Console.WriteLine(csvArray.Length);
            }
            return listData;
        }