Пример #1
0
        public static IEnumerable <string[]> ImportLines(Stream stream, CsvImportSettings settings)
        {
            TextReader input;

            if (string.IsNullOrWhiteSpace(settings.Encoding))
            {
                input = new StreamReader(stream);
            }
            else
            {
                input = new StreamReader(stream, Encoding.GetEncoding(settings.Encoding));
            }

            var csvReaderSettings = new CsvReaderSettings
            {
                MaxTokenLength                           = 1024 * 1024,
                SkipFirstLine                            = settings.SkipFirstLine,
                SkipEmptyLines                           = settings.SkipEmptyLines,
                Quotes                                   = settings.StringQuoting != null?settings.StringQuoting.ToCharArray() : null,
                                              Delimiters = settings.Delimiters != null?settings.Delimiters.ToCharArray() : null,
                                                               StartOfComment           = settings.CommentSymbol,
                                                               EscapedStrings           = settings.Escaping,
                                                               TwoQuotationMarkEscaping = settings.TwoQuotationMarksEscape,
                                                               MultilineStrings         = settings.MultilineStrings
            };

            var csvReader = new CsvReader(csvReaderSettings);

            return(csvReader.Read(input));
        }
Пример #2
0
 public CsvReader(CsvReaderSettings settings)
 {
     this.settings = settings;
 }