Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created July 1, 2018 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NMZivkovic/0938aa828f55791ea98d511ef1398133 to your computer and use it in GitHub Desktop.
Save NMZivkovic/0938aa828f55791ea98d511ef1398133 to your computer and use it in GitHub Desktop.
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