예제 #1
0
        public static void ExcelToJsonSeries(DataItem di)
        {
            Func <int, string, string> downloadMethod = (int p1, string p2) => p2.Substring(p1);

            var er = new Utils.ExcelReader();
            var nd = new DataDownloader();
            var p  = nd.BuildFileName(DataItem.Elspot_Prices, Resolution.Hourly, FromYear(2013), Currency.EUR);
            var hd = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + p, 3);

            p = nd.BuildFileName(DataItem.Elspot_Prices, Resolution.Hourly, FromYear(2014), Currency.EUR);
            var hd1 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + p, 3);

            hd.AddRange(hd1);

            p = nd.BuildFileName(DataItem.Elspot_Prices, Resolution.Hourly, FromYear(2015), Currency.EUR);
            var hd2 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + p, 3);

            hd.AddRange(hd2);

            // do here some preprocessing?... interpolate missing and ourliers... but not spikes
            var negvs = hd.Where(x => x.Value < 0).ToList();
            var nulls = hd.Where(x => !x.Value.HasValue).ToList();

            var name = nd.BuildFileName(DataItem.Elspot_Prices, Resolution.Hourly, Currency.EUR);

            nd.SaveFileAsJson(GetAppDataServerPath() + name + ".json", hd);
        }
예제 #2
0
        public static void ExcelToJsonSeriesPredictors2(DataItem di)
        {
            var er = new Utils.ExcelReader();

            Func <string, int, int, List <HistoricalPrice> > excelRead = (string path, int fromColumn, int toColumn) =>
            {
                var cols = new List <List <HistoricalPrice> >();
                for (int i = fromColumn; i <= toColumn; i++)
                {
                    cols.Add(er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + path, i));
                }

                //needs to be done, since the sum is not already consistently calculated
                //assumed same data lengths, ofc
                for (int i = 0; i < cols[0].Count; i++)
                {
                    decimal?val = 0m;

                    for (int j = 1; j < cols.Count; j++)
                    {
                        val += cols[j][i].Value;
                    }

                    cols[0][i].Value += val;
                }

                return(cols[0]);
            };

            var nd = new DataDownloader();

            Func <int, List <HistoricalPrice> > readYear = (int year) =>
            {
                var p = nd.BuildFileName(di, Resolution.Hourly, FromYear(year));
                if (di == DataItem.Consumption_Prognosis)
                {
                    return(excelRead(p, 3, 7));
                }
                else
                {
                    return(excelRead(p, 3, 14));
                }
            };

            var hd = readYear(2013);

            hd.AddRange(readYear(2014));
            hd.AddRange(readYear(2015));

            // do here some preprocessing?... interpolate missing and ourliers... but not spikes
            var negvs = hd.Where(x => x.Value < 0).ToList();
            var nulls = hd.Where(x => !x.Value.HasValue).ToList();

            var name = nd.BuildFileName(di, Country.All, Resolution.Hourly);

            nd.SaveFileAsJson(GetAppDataServerPath() + name + ".json", hd);
        }
예제 #3
0
        //only for consumption and production...
        public static void ExcelToJsonSeriesPredictors1(DataItem di)
        {
            var er = new Utils.ExcelReader();

            Func <string, List <HistoricalPrice> > excelRead = (string path) =>
            {
                var hdx1 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + path, 3);
                var hdx2 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + path, 4);
                var hdx3 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + path, 5);
                var hdx4 = er.ReadNordPoolSpotHistoricalPricesInterop(DataDownloader.SavePath + path, 6);

                //needs to be done, since the sum is not already consistently calculated
                for (int i = 0; i < hdx1.Count; i++)
                {
                    hdx1[i].Value = hdx2[i].Value + hdx3[i].Value + hdx4[i].Value;
                }

                return(hdx1);
            };

            var nd = new DataDownloader();

            Func <int, List <HistoricalPrice> > readYear = (int year) =>
            {
                var p = nd.BuildFileName(di, Country.All, Resolution.Hourly, FromYear(year));
                return(excelRead(p));
            };

            var hd = readYear(2013);

            hd.AddRange(readYear(2014));
            hd.AddRange(readYear(2015));

            // do here some preprocessing?... interpolate missing and ourliers... but not spikes
            var negvs = hd.Where(x => x.Value < 0).ToList();
            var nulls = hd.Where(x => !x.Value.HasValue).ToList();

            var name = nd.BuildFileName(di, Country.All, Resolution.Hourly);

            nd.SaveFileAsJson(GetAppDataServerPath() + name + ".json", hd);
        }