public static void Sample_Csv_To_Fixed() { string sampleDataPath = @"..\..\Samples\"; var watch = new Stopwatch(); using (var reader = new CsvAdapter()) { reader.FileName = sampleDataPath + @"cd-Daten.txt"; reader.Enclosure = "\""; reader.Separator = ";"; using (var writer = new FixedTextAdapter()) { writer.FileName = Path.Combine(Path.GetDirectoryName(reader.FileName), "cd-Daten-Fixed.txt"); watch.Start(); int lineCount = 0; reader.ReadDataAs <CdDaten>(30) .ForEach(x => { lineCount += 1; }) .Do(x => writer.WriteDataFrom <CdDaten>(x, false, 30)); watch.Stop(); Console.WriteLine("lineCount=" + lineCount + ", Time=" + watch.Elapsed); Console.ReadLine(); } } }
public void Test_Formats_To_Obj_Conversion() { var watch = new Stopwatch(); using (var reader = new CsvAdapter()) { reader.FileName = Path.Combine(this.testDataPath, @"DataFormats.txt"); reader.Enclosure = "\""; reader.Separator = ";"; using (var writer = new FixedTextAdapter()) { writer.FileName = Path.Combine(this.resultPath, @"DataFormats-Fixed.txt"); watch.Start(); int lineCount = 0; reader.ReadDataAs <DataFormatTest>(30) .ForEach(x => { Console.WriteLine(x.ToString()); lineCount += 1; }) .Do(x => writer.WriteDataFrom <DataFormatTest>(x, false, 30)); watch.Stop(); Console.WriteLine("lineCount=" + lineCount + ", Time=" + watch.Elapsed); // check var targetlineCount = File.ReadLines(this.resultPath + @"DataFormats-Fixed.txt").Count(); Assert.AreEqual(6, targetlineCount); } } }
public static void Sample_Csv_To_Sqlite() { string sampleDataPath = @"..\..\Samples\"; var watch = new Stopwatch(); using (var reader = new CsvAdapter()) { reader.FileName = sampleDataPath + @"cd-Daten.txt"; reader.Enclosure = "\""; reader.Separator = ";"; using (var writer = new SqliteAdapter()) { writer.FileName = sampleDataPath + @"cd-Daten.sqlite"; writer.CreateNewFile(); if (!writer.Connect()) { throw new Exception("No connection"); } watch.Start(); int lineCount = 0; reader.ReadDataAs <CdDaten>(30) .ForEach(x => { lineCount += 1; }) .Do(x => writer.WriteDataFrom <CdDaten>(x, false, 30)); writer.Disconnect(); watch.Stop(); Console.WriteLine("lineCount=" + lineCount + ", Time=" + watch.Elapsed); Console.ReadLine(); } } }