public DelimitedHeader Elect(Spreadsheet spreadsheet)
        {
            var spreadsheetElector = new SpreadsheetColumnTypeDetector();
            var columns            = spreadsheetElector.Elect(spreadsheet)
                                     .ToArray();

            bool hasHeader   = this.HasHeader(columns);
            var  columnNames = hasHeader ?
                               spreadsheet.GetRow(0) :
                               this.GetDefaultColumnNames(spreadsheet.Columns);

            var columnTypes = hasHeader ?
                              columns.Select(x => x.TypeOfNonHeaderRows) :
                              columns.Select(x => x.TypeOfAllRows);

            var delimitedColumns = columnNames
                                   .Zip(columnTypes, (name, type) => new DelimitedColumn {
                Name = name, Type = type
            });

            var delimitedHeader = new DelimitedHeader(
                delimitedColumns);

            return(delimitedHeader);
        }
Exemple #2
0
        private DelimitedParser(
            DelimitedParserSettings settings,
            CharReader reader)
        {
            this.header    = settings.DelimitedHeader;
            this.reader    = reader;
            this.delimiter = settings.Delimiter;

            this.row = new string[header.Count];
        }