Created
July 1, 2018 16:35
-
-
Save NMZivkovic/0938aa828f55791ea98d511ef1398133 to your computer and use it in GitHub Desktop.
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
public class WineQualityCsvReader | |
{ | |
public IEnumerable<WineQualitySample> GetWineQualitySamplesFromCsv(string dataLocation) | |
{ | |
return File.ReadAllLines(dataLocation) | |
.Skip(1) | |
.Select(x => x.Split(';')) | |
.Select(x => new WineQualitySample() | |
{ | |
FixedAcidity = float.Parse(x[0]), | |
VolatileAcidity = float.Parse(x[1]), | |
CitricAcid = float.Parse(x[2]), | |
ResidualSugar = float.Parse(x[3]), | |
Chlorides = float.Parse(x[4]), | |
FreeSulfurDioxide = float.Parse(x[5]), | |
TotalSulfurDioxide = float.Parse(x[6]), | |
Density = float.Parse(x[7]), | |
Ph = float.Parse(x[8]), | |
Sulphates = float.Parse(x[9]), | |
Alcohol = float.Parse(x[10]), | |
Label = float.Parse(x[11]) | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment