Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@NMZivkovic
Created June 17, 2018 14:24
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/ee4ebdd58ed65cc72d9f4e36f91a567c to your computer and use it in GitHub Desktop.
Save NMZivkovic/ee4ebdd58ed65cc72d9f4e36f91a567c to your computer and use it in GitHub Desktop.
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