/// <summary>
        /// Parses a CSV text line and returns back again the complete line as CSV string.
        /// </summary>
        /// <param name="csvLineReader">The <see cref="CsvLineParser"/></param>
        /// <param name="line">A CSV formated text line</param>
        /// <returns>
        /// The complete row as CSV string if values are available; otherwise null.
        /// </returns>
        public static string Validate(this CsvLineParser csvLineReader, string line)
        {
            var csvLineBuilder = new CsvLineBuilder()
            {
                Configuration = csvLineReader.Configuration
            };

            return((csvLineReader.Read(line, (i, s) => { csvLineBuilder.Append(s); }) > 0) ? csvLineBuilder.ToString() : null);
        }
        /// <summary>
        /// Parses a CSV text line and gives back the values as string collection.
        /// </summary>
        /// <param name="csvLineReader">The <see cref="CsvLineParser"/></param>
        /// <param name="line">A CSV formated text line.</param>
        /// <param name="values">List of parsed values.</param>
        /// <returns>
        /// Number of parsed values
        /// </returns>
        public static int Read(this CsvLineParser csvLineReader, string line, ICollection <string> values)
        {
            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            values.Clear();

            return(csvLineReader.Read(line, (i, s) => { values.Add(s); }));
        }
        /// <summary>
        /// Parses a CSV text line and gives back the values as string array.
        /// </summary>
        /// <param name="csvLineReader">The <see cref="CsvLineParser"/></param>
        /// <param name="line">A CSV formated text line</param>
        /// <returns>
        /// Array of parsed values.
        /// </returns>
        public static string[] Read(this CsvLineParser csvLineReader, string line)
        {
            var values = new List <string>();

            return((csvLineReader.Read(line, (i, s) => { values.Add(s); }) > 0) ? values.ToArray() : null);
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvLineTableReader"/> class.
 /// </summary>
 /// <param name="csvLineParser">The <see cref="CsvLineParser"/> as string parser</param>
 /// <param name="csvConverterResolver">Your own implementation of a value converter resolver</param>
 /// <param name="csvHeaders">List of csv headers</param>
 public CsvLineTableReader(CsvLineParser csvLineParser, ICsvConverterResolver csvConverterResolver, CsvHeaders csvHeaders)
     : base(csvHeaders, csvConverterResolver)
 {
     _csvLineParser = csvLineParser;
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvLineTableReader"/> class.
 /// </summary>
 /// <param name="csvLineParser">The <see cref="CsvLineParser"/> as string parser</param>
 /// <param name="csvConverterResolver">Your own implementation of a value converter resolver</param>
 /// <param name="csvHeaders">List of csv headers</param>
 public CsvLineTableReader(CsvLineParser csvLineParser, ICsvConverterResolver csvConverterResolver, params string[] csvHeaders)
     : this(csvLineParser, csvConverterResolver, new CsvHeaders(csvHeaders))
 {
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvLineTableReader"/> class.
 /// </summary>
 /// <param name="csvLineParser">The <see cref="CsvLineParser"/> as string parser</param>
 /// <param name="csvHeaders">List of csv headers</param>
 public CsvLineTableReader(CsvLineParser csvLineParser, IList <string> csvHeaders)
     : this(csvLineParser, new CsvHeaders(csvHeaders))
 {
 }
Example #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvLineTableReader"/> class.
 /// </summary>
 /// <param name="csvLineParser">The <see cref="CsvLineParser"/> as string parser</param>
 /// <param name="csvHeaders">List of csv headers</param>
 public CsvLineTableReader(CsvLineParser csvLineParser, params string[] csvHeaders)
     : this(csvLineParser, new CsvHeaders(csvHeaders))
 {
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvLineTableReader"/> class.
 /// </summary>
 /// <param name="csvLineParser">The <see cref="CsvLineParser"/> as string parser</param>
 /// <param name="csvHeaders">List of csv headers</param>
 public CsvLineTableReader(CsvLineParser csvLineParser, CsvHeaders csvHeaders)
     : base(csvHeaders)
 {
     _csvLineParser = csvLineParser;
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvLineTableReader"/> class.
 /// </summary>
 /// <param name="csvLineParser">The <see cref="CsvLineParser"/> as string parser</param>
 public CsvLineTableReader(CsvLineParser csvLineParser)
     : base()
 {
     _csvLineParser = csvLineParser;
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvLineTableReader"/> class.
 /// </summary>
 /// <param name="csvLineParser">The <see cref="CsvLineParser"/> as string parser</param>
 /// <param name="csvConverterResolver">Your own implementation of a value converter resolver</param>
 /// <param name="csvHeaders">List of csv headers</param>
 public CsvLineTableReader(CsvLineParser csvLineParser, ICsvConverterResolver csvConverterResolver, IList <string> csvHeaders)
     : this(csvLineParser, csvConverterResolver, new CsvHeaders(csvHeaders))
 {
 }