Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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