Implement CSV reading in CreateListFromCsv method
This commit is contained in:
parent
02ff071ebe
commit
63d956d7c1
1 changed files with 11 additions and 1 deletions
|
|
@ -27,6 +27,16 @@ return;
|
||||||
static ExamList CreateListFromCsv(string fileName)
|
static ExamList CreateListFromCsv(string fileName)
|
||||||
{
|
{
|
||||||
var testList = new ExamList();
|
var testList = new ExamList();
|
||||||
// TODO read CSV file
|
var lines = File.ReadAllLines(fileName);
|
||||||
|
|
||||||
|
// Skip header line
|
||||||
|
for (int i = 1; i < lines.Length; i++)
|
||||||
|
{
|
||||||
|
var columns = lines[i].Split(';');
|
||||||
|
var date = DateTime.ParseExact(columns[4], "dd.MM.yy", null);
|
||||||
|
var exam = new Exam(columns[2], date, columns[3]);
|
||||||
|
testList.Insert(exam);
|
||||||
|
}
|
||||||
|
|
||||||
return testList;
|
return testList;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue