示例#1
0
        public void Add(CSVLine line)
        {
            var columnCount = line.Values().Count;

            if (columnCount != myColumnCount)
            {
                throw new ArgumentException($"Column count {columnCount} does not match expected column count of {myColumnCount}");
            }
            myLines.Add(line);
        }
示例#2
0
        public List <CSVLine> ReadLines()
        {
            var result = new List <CSVLine>();

            using (var reader = new StreamReader(myPath))
            {
                while (!reader.EndOfStream)
                {
                    var line        = reader.ReadLine();
                    var values      = line.Split(myDelimiter);
                    var currentLine = new CSVLine();
                    currentLine.AddAll(values);
                    result.Add(currentLine);
                }
            }
            return(result);
        }