Beispiel #1
0
        //[Benchmark]
        public void FastCsvParser()
        {
            var s   = TestData.GetUtf8Stream();
            var csv = new CsvParser.CsvReader(s, System.Text.Encoding.UTF8);

            while (csv.MoveNext())
            {
                var row = csv.Current;
                for (int i = 0; i < row.Count; i++)
                {
                    var str = row[i];
                }
            }
        }
Beispiel #2
0
        public List <T> GetRecords <T>(MemoryStream stream) where T : ICsvReadable, new()
        {
            var activate   = ActivatorFactory.Create <T>(_activationMethod);
            var allRecords = new List <T>();

            using (var parser = new CsvParser.CsvReader(stream, Encoding.UTF8))
            {
                while (parser.MoveNext())
                {
                    var record = activate();
                    record.Read(i => parser.Current[i]);
                    allRecords.Add(record);
                }
            }

            return(allRecords);
        }