private RlmProfile ImportOneProfile([NotNull] FileInfo filename) { var multiplier = 0; if (filename.Name.Contains("_Bezug")) { multiplier = -1; } if (filename.Name.Contains("_Abgabe")) { multiplier = 1; } if (multiplier == 0) { throw new Exception("Unknown profile type:" + filename.Name); } Info("Importing " + filename.Name); ExcelHelper eh = new ExcelHelper(Services.Logger, MyStage); var arr = eh.ExtractDataFromExcel2(filename.FullName, 2, "A1", "F35041", out var _); var hdict = new Dictionary <string, int>(); for (var i = 0; i < arr.GetLength(1); i++) { var o = arr[0, i]; if (o == null) { continue; } hdict.Add(o.ToString(), i); } var vals = new double[35040]; var dtlookup = new Dictionary <DateTime, int>(); var d = new DateTime(2017, 1, 1); for (var i = 0; i < 35040; i++) { dtlookup.Add(d, i); d = d.AddMinutes(15); } for (var row = 1; row < arr.GetLength(0); row++) { if (arr[row, hdict["Zeitpunkt (Beginn Messung)"]] == null) { continue; } if (string.IsNullOrWhiteSpace(arr[row, hdict["Zeitpunkt (Beginn Messung)"]].ToString())) { continue; } var dt = Helpers.GetDateTime(arr[row, hdict["Zeitpunkt (Beginn Messung)"]]); var idx = dtlookup[dt]; vals[idx] = multiplier * Helpers.GetNoNullDouble(arr[row, hdict["Wert"]]); var unit = Helpers.GetString(arr[row, hdict["Einheit"]]); if (unit != "kW") { throw new Exception("unit not kw in file:" + filename.FullName); } } var lstvals = new List <double>(vals); var prof = new JsonSerializableProfile(filename.Name, lstvals.AsReadOnly(), EnergyOrPower.Power); var a = new RlmProfile(filename.Name, 0, prof); if (a.Profile.Values.Any(x => double.IsNaN(x))) { throw new FlaException("Profile was broken: " + filename.FullName); } return(a); }