Ejemplo n.º 1
0
 /// <summary>
 /// Parses a CSV string into a <see cref="DataTable"/>.
 /// </summary>
 /// <param name="csv">The CSV string to parse.</param>
 /// <returns>The parsed <see cref="DataTable"/>.</returns>
 public static DataTable ReadDataTableFromString(string csv)
 {
     using (var reader = new StringReader(csv))
         return(CsvParser.CreateDataTable(reader));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvReader"/> class.
 /// </summary>
 /// <param name="fileName">The name of the files to read the CSV <see cref="CsvParser.Token"/> from.</param>
 public CsvReader(string fileName)
 {
     _reader           = new StreamReader(fileName);
     _tokensEnumerator = CsvParser.Parse(_reader).GetEnumerator();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the new row of CSV value strings from the token list.
 /// </summary>
 /// <returns>A list of CSV value strings.</returns>
 public IList <string> GetNextRow()
 {
     return(CsvParser.GetNextRow(_tokensEnumerator));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Parses a CSV file into a <see cref="DataTable"/>.
 /// </summary>
 /// <param name="file">The CSV file to parse.</param>
 /// <returns>The parsed <see cref="DataTable"/>.</returns>
 public static DataTable ReadDataTableFromFile(string file)
 {
     using (var reader = new StreamReader(file))
         return(CsvParser.CreateDataTable(reader));
 }