private IEnumerable <object[]> GetRows(TextFieldParserBuffer parser)
 {
     for (int i = 0; (!_takeLines.HasValue || i < _takeLines.Value) && !parser.EndOfData; i++)
     {
         yield return(parser.ReadFields());
     }
 }
        private List <string> ReadColumnNames(TextFieldParserBuffer parser)
        {
            var srcColNames = new List <string>();

            if (_headerRow)
            {
                // read the column header row
                var cells = parser.ReadFields();
                if (cells == null)
                {
                    // end of file; there is nothing here.
                    if (_skipLines == 0)
                    {
                        throw new Exception("No column header row was found because the file is empty.");
                    }
                    else
                    {
                        throw new Exception("No column header row was found because all rows were skipped.");
                    }
                }

                // add a numeric suffix to each column name if necessary to make them all unique
                foreach (var cell in cells)
                {
                    var testName = cell;
                    var testNum  = 1;
                    while (srcColNames.Contains(testName))
                    {
                        testNum++;
                        testName = $"{cell}{testNum}";
                    }
                    srcColNames.Add(testName);
                }
            }
            else
            {
                // no header row so use "column1", "column2", etc. based on the first row of data
                var fields = parser.PeekFields();
                if (fields == null || !fields.Any())
                {
                    // treat empty file as a single column with no rows
                    srcColNames.Add("column1");
                }
                else
                {
                    for (int i = 0; i < fields.Length; i++)
                    {
                        srcColNames.Add($"column{i + 1}");
                    }
                }
            }

            return(srcColNames);
        }