public CsvParser(TextReader textReader, CsvLayout layOut, CsvBehaviour behaviour) { _csvStateMachine = new CsvStateMachine(textReader, layOut, behaviour); _enumerator = _csvStateMachine.Lines().GetEnumerator(); _textReader = textReader; var firstLine = Lines().FirstOrDefault(); Header = (layOut, firstLine) switch { ({ Schema : not null }, _)
public CsvParser(TextReader textReader, CsvLayout layOut, CsvBehaviour behaviour, string defaultHeaderName = "Column") { _csvStateMachine = new CsvStateMachine(textReader, layOut, behaviour); _enumerator = _csvStateMachine.Lines().GetEnumerator(); _layout = layOut; _defaultHeaderName = defaultHeaderName ?? "Column"; _textReader = textReader; var firstLine = Lines().FirstOrDefault(); if (_layout.HasHeaders && firstLine != null) { Header = new CsvHeader(firstLine.Fields, _defaultHeaderName); } else { _cachedLine = firstLine; } }