Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class IrisCsvReader
{
public IEnumerable<IrisFlower> GetIrisDataFromCsv(string dataLocation)
{
return File.ReadAllLines(dataLocation)
.Skip(1)
.Select(x => x.Split(','))
.Select(x => new IrisFlower()
{
SepalLength = float.Parse(x[0]),
SepalWidth = float.Parse(x[1]),
PetalLength = float.Parse(x[2]),
PetalWidth = float.Parse(x[3]),
Label = x[4]
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment