예제 #1
0
파일: CsvParser.cs 프로젝트: lanicon/netcsv
        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 }, _)
예제 #2
0
파일: CsvParser.cs 프로젝트: MaziarM/netcsv
        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;
            }
        }