blob: 904bab38f1809eb29d89c3a1f1fb43a57f747b59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
using System.Collections;
namespace RhSolutions.ML.Tests;
public abstract class DatasetBase : IEnumerable
{
protected virtual string FileName {get;set;} = string.Empty;
public IEnumerator GetEnumerator()
{
string path = Path.Combine("..", "..", "..", "TestData", $"{FileName}.csv");
using FileStream stream = new(path, FileMode.Open, FileAccess.Read);
StreamReader reader = new(stream);
string? inputLine = reader.ReadLine();
while (inputLine != null)
{
var data = inputLine.Split(';');
yield return new Product { Name = data[0], Type = data[1] };
inputLine = reader.ReadLine();
}
reader.Close();
stream.Close();
}
}
|