public void AutoRemoveQuotes() { CsvEngine eng = new CsvEngine(new CsvOptions("YourClass", ',', 2, 0)); DataTable dt = eng.ReadFileAsDT(TestCommon.GetPath("Good", "QuoteMode1.txt")); Assert.AreEqual("VINET", dt.Rows[0][1]); }
/// <summary> /// Reads a CSV File and return their contents as /// DataTable /// </summary> /// <param name="filename">The file to read.</param> /// <param name="options">The options used to create the record mapping class.</param> /// <returns>The contents of the file as a DataTable</returns> public static DataTable CsvToDataTable(string filename, CsvOptions options) { var engine = new CsvEngine(options); #pragma warning disable 618 return(engine.ReadFileAsDT(filename)); #pragma warning restore 618 }
public void ReadFileHeader1() { string file = TestCommon.GetPath("Good", "RealCsvComma1.txt"); string classname = "CustomerComma"; char delimiter = ','; CsvOptions options = new CsvOptions(classname, delimiter, file); options.HeaderLines = 0; CsvEngine engine = new CsvEngine(options); Assert.AreEqual(classname, engine.RecordType.Name); DataTable dt = engine.ReadFileAsDT(file); Assert.AreEqual(21, dt.Rows.Count); Assert.AreEqual(21, engine.TotalRecords); Assert.AreEqual(0, engine.ErrorManager.ErrorCount); Assert.AreEqual("Field_0", dt.Columns[0].ColumnName); }
/// <summary> /// Reads a CSV File and return their contents as /// DataTable /// </summary> /// <param name="filename">The file to read.</param> /// <param name="options">The options used to create the record mapping class.</param> /// <returns>The contents of the file as a DataTable</returns> public static DataTable CsvToDataTable(string filename, CsvOptions options) { var engine = new CsvEngine(options); return(engine.ReadFileAsDT(filename)); }
/// <summary> /// Reads a CSV File and return their contents as /// DataTable /// </summary> /// <param name="filename">The file to read.</param> /// <param name="options">The options used to create the record mapping class.</param> /// <returns>The contents of the file as a DataTable</returns> public static DataTable CsvToDataTable(string filename, CsvOptions options) { CsvEngine engine = new CsvEngine(options); return engine.ReadFileAsDT(filename); }
private void RunTest(string file, char delimiter, char delimiterHdr, string classname) { CsvOptions options = new CsvOptions(classname, delimiter, file); options.HeaderDelimiter = delimiterHdr; CsvEngine engine = new CsvEngine(options); Assert.AreEqual(classname, engine.RecordType.Name); DataTable dt = engine.ReadFileAsDT(file); Assert.AreEqual(20, dt.Rows.Count); Assert.AreEqual(20, engine.TotalRecords); Assert.AreEqual(0, engine.ErrorManager.ErrorCount); Assert.AreEqual("CustomerID", dt.Columns[0].ColumnName); }