Esempio n. 1
0
        public static CsvImporter Import(StreamReader reader)
        {
            var importer = new CsvImporter();

            using (var csv = new CsvReader(reader))
            {
                csv.Configuration.PrepareHeaderForMatch = header => header.Replace(" ", string.Empty);
                importer.Records = csv.GetRecords <dynamic>().ToList();
            }

            return(importer);
        }
        public void ImportRecords()
        {
            Console.WriteLine("Importing CSV records.");

            var csv = CsvImporter.Import(downloadStream);

            sourceRecords = csv.Records;

            if (sourceRecords.Count == 0)
            {
                throw new Exception("0 records to convert.");
            }

            records = importScript.ConvertRecords(sourceRecords).ToList();

            Console.WriteLine("{0} records converted.", records.Count);
        }