/// <summary> /// Read a CSV file into a table /// </summary> /// <param name="filename">Filename of CSV file</param> /// <param name="headerRow">True if the first row contains column names</param> /// <param name="scanRows">The number of rows to scan for types when building a DataTable (0 to scan the whole file)</param> /// <returns>System.Data.DataTable object that contains the CSV data</returns> public static DataTable ReadCSVFile(string filename, bool headerRow, int scanRows) { using (CSVReader reader = new CSVReader(new FileInfo(filename))) { reader.ScanRows = scanRows; return reader.CreateDataTable(headerRow); } }
/// <summary> /// Read a CSV file into a table /// </summary> /// <param name="filename">Filename of CSV file</param> /// <param name="headerRow">True if the first row contains column names</param> /// <returns>System.Data.DataTable object that contains the CSV data</returns> public static DataTable ReadCSVFile(string filename, bool headerRow) { using (CSVReader reader = new CSVReader(new FileInfo(filename))) return reader.CreateDataTable(headerRow); }
/// <summary> /// Convert a CSV-formatted string into a DataTable /// </summary> /// <param name="headerRow">True if the first row contains headers</param> /// <returns>System.Data.DataTable that contains the CSV data</returns> public static DataTable ReadCSVTable(this string input, bool headerRow) { using (CSVReader reader = new CSVReader(input)) return reader.CreateDataTable(headerRow); }
/// <summary> /// Convert a CSV-formatted string into a list of objects /// </summary> /// <returns>List of objects that contains the CSV data</returns> public static List<object> ReadCSVLine(this string input) { using (CSVReader reader = new CSVReader(input)) return reader.ReadRow(); }
/// <summary> /// Convert a CSV-formatted string into a DataTable /// </summary> /// <param name="headerRow">True if the first row contains headers</param> /// <returns>System.Data.DataTable that contains the CSV data</returns> public static DataTable ReadCSVTable(this string input, bool headerRow) { using (CSVReader reader = new CSVReader(input)) return(reader.CreateDataTable(headerRow)); }
/// <summary> /// Convert a CSV-formatted string into a list of objects /// </summary> /// <returns>List of objects that contains the CSV data</returns> public static List <object> ReadCSVLine(this string input) { using (CSVReader reader = new CSVReader(input)) return(reader.ReadRow()); }
/// <summary> /// Read a CSV file into a table /// </summary> /// <param name="filename">Filename of CSV file</param> /// <param name="headerRow">True if the first row contains column names</param> /// <returns>System.Data.DataTable object that contains the CSV data</returns> public static DataTable ReadCSVFile(string filename, bool headerRow) { using (CSVReader reader = new CSVReader(new FileInfo(filename))) return(reader.CreateDataTable(headerRow)); }