using System.Globalization;
public static void Main()
typeof(ChoCSVReader).GetAssemblyVersion().Print();
string csv = @"OrderNo, OrderName, Street, City, Zip
1, Name1, Main Street, New York, 10010";
var config = new ChoCSVRecordConfiguration<SalesOrder>()
.Configure(c => c.ThrowAndStopOnMissingField = false)
.Configure(c => c.IgnoreEmptyLine = true)
.Configure(c => c.FileHeaderConfiguration.IgnoreColumnsWithEmptyHeader = true);
config.Map(f => f.SalesAddress.Street, "Street");
config.Map(f => f.SalesAddress.City, "City");
config.Map(f => f.SalesAddress.Zip, "Zip");
using (var r = ChoCSVReader<SalesOrder>.LoadText(csv, config)
public class SalesAddress
[ChoTypeConverter(typeof(StringToCustomStringConverter))]
public CustomString Street { get; set; }
[ChoTypeConverter(typeof(StringToCustomStringConverter))]
public CustomString City { get; set; }
[ChoTypeConverter(typeof(StringToCustomStringConverter))]
public CustomString Zip { get; set; }
public string OrderNo { get; set; }
public string OrderName { get; set; }
public SalesAddress SalesAddress { get; set; }
public struct CustomString
public string Value { get; }
public CustomString(string val)
if (string.IsNullOrWhiteSpace(val))
public static implicit operator string(CustomString s) => s.Value;
public static explicit operator CustomString(string s) => new CustomString(s);
public override string ToString() => Value;
public class StringToCustomStringConverter : IChoValueConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
"Calling converter".Print();
return new CustomString(val);
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
throw new NotImplementedException();