Beispiel #1
0
 public TypedCsvRecord(T value, CsvFormat format)
 {
     Record = CsvRecord.From(value, format);
     Value  = value;
 }
Beispiel #2
0
 public CsvRecord WithFormat(CsvFormat format)
 {
     return(new CsvRecord(Header?.WithFormat(format), _values, format));
 }
Beispiel #3
0
 public string ToString(CsvFormat format)
 {
     return(CsvUtility.ToCsvString(_values, format));
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvWriter"/> class.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="format">The format.</param>
 public CsvWriter(string path, CsvFormat format) : this(path, format, flexible : false)
 {
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvWriter"/> class.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="format">The format.</param>
 /// <param name="flexible">if set to <c>true</c> the writer will allow records of diferent lenghts.</param>
 public CsvWriter(string path, CsvFormat format, bool flexible) : this(new StreamWriter(path, append : true), format, flexible)
 {
 }
Beispiel #6
0
 /// <summary>
 /// Creates a csv header from the specified values and format.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <param name="values">The values.</param>
 /// <returns>A csv header with the specified values</returns>
 public static CsvHeader FromValues(CsvFormat format, params string[] values)
 {
     return(new CsvHeader(values, format));
 }
Beispiel #7
0
        /// <summary>
        /// Creates a csv header for the specified type.
        /// </summary>
        /// <typeparam name="T">Type used to create the header</typeparam>
        /// <param name="format">The format.</param>
        /// <returns>The header using the names of the public fields and properties of the specified type.</returns>
        public static CsvHeader FromType <T>(CsvFormat format)
        {
            var values = CsvUtility.GetHeader <T>();

            return(new CsvHeader(values, format));
        }
Beispiel #8
0
 /// <summary>
 /// Creates a copy of this document with the specified csv format.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <returns>A copy using the specified format.</returns>
 public CsvDocument WithFormat(CsvFormat format)
 {
     return(new CsvDocument(_records.ToList(), Header.WithFormat(format), format, IsFlexible));
 }
Beispiel #9
0
 public CsvHeader WithFormat(CsvFormat format)
 {
     return(new CsvHeader(_values, format));
 }
Beispiel #10
0
 public CsvDocument(IEnumerable <string> header, CsvFormat format) : this(header, format, false)
 {
 }
Beispiel #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvReader"/> class.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="format">The format.</param>
 /// <param name="hasHeader">if set to <c>true</c> the first record will be considered the header.</param>
 public CsvReader(string path, CsvFormat format, bool hasHeader) : this(new StreamReader(path), format, hasHeader)
 {
 }
Beispiel #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvReader"/> class.
 /// </summary>
 /// <param name="path">The path.</param>
 /// <param name="format">The format.</param>
 public CsvReader(string path, CsvFormat format) : this(path, format, true)
 {
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CsvDocument{T}"/> class.
 /// </summary>
 /// <param name="format">The format.</param>
 public CsvDocument(CsvFormat format)
 {
     Header = new CsvHeader(CsvUtility.GetHeader <T>(), format);
     Format = format;
 }
Beispiel #14
0
 /// <summary>
 /// Gets a copy of this csv with the specified format.
 /// </summary>
 /// <param name="format">The format.</param>
 /// <returns></returns>
 public CsvDocument <T> WithFormat(CsvFormat format)
 {
     return(new CsvDocument <T>(_records.ToList(), Header.WithFormat(format), format));
 }