// Copyright Epic Games, Inc. All Rights Reserved. using System.IO; using System.Collections.Generic; using AutomationTool; namespace Gauntlet { public static class CSVParser { public static List> Load(string File) { List> Rows = new List>(); // Parse csv file using (StreamReader Reader = new StreamReader(File)) { // Parse Header string FirstLine = Reader.ReadLine(); int LineNumber = 1; string[] HeaderValues = FirstLine.Split(','); // Parse the rest of the data while (!Reader.EndOfStream) { Dictionary OneRow = new Dictionary(); string Line = Reader.ReadLine(); LineNumber++; string[] Values = Line.Split(','); if (Values.Length >= HeaderValues.Length) { for (int i = 0; i < HeaderValues.Length; i++) { OneRow[HeaderValues[i]] = Values[i]; } Rows.Add(OneRow); } else { throw new AutomationException(string.Format("Not enough number of columns at line {0}.", LineNumber)); } } } return Rows; } } }