Last active
December 18, 2019 23:56
-
-
Save icebeam7/ea0ffb2d43433557f272930e3875b92c to your computer and use it in GitHub Desktop.
AnomalyDetector: FileService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Reflection; | |
using System.Collections.Generic; | |
using AdExchangeAnalyzer.Models; | |
namespace AdExchangeAnalyzer.Services | |
{ | |
public static class FileService | |
{ | |
public static List<DataPoint> ReadFile() | |
{ | |
var assembly = IntrospectionExtensions.GetTypeInfo(typeof(FileService)).Assembly; | |
var fullName = $"AdExchangeAnalyzer.Data.data.csv"; | |
var stream = assembly.GetManifestResourceStream(fullName); | |
var series = new List<DataPoint>(); | |
using (var reader = new StreamReader(stream)) | |
{ | |
var line = string.Empty; | |
while ((line = reader.ReadLine()) != null) | |
{ | |
var data = line.Split(','); | |
if (data.Length == 2) | |
{ | |
series.Add(new DataPoint() | |
{ | |
Timestamp = DateTime.Parse(data[0]).ToUniversalTime(), | |
Value = float.Parse(data[1]) | |
}); | |
} | |
} | |
} | |
return series; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment