ChoETL: ChoETL CSVWriter is not handling double quotes correctly.

When a string has a Double Quote Char it needs to be doubled up…

class EmployeeRecSimple
{
    public int Id { get; set; }
    public string Name { get; set; }
}

static void Main(string[] args)
{
    List<EmployeeRecSimple> objs = new List<EmployeeRecSimple>()
    {
        new EmployeeRecSimple() { Id = 20, Name = "John Smith" },
        new EmployeeRecSimple() { Id = 21, Name = "Jack in \"Da Box" }
    };
    Console.WriteLine(ChoCSVWriter.ToText(objs));
    Console.ReadLine();
}

the output is:

20,John Smith
21,Jack in "Da Box

the second line needs to be change to…

21,"Jack in ""Da Box"

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

U must use QuoteAllFields() when loading csv file

            using (var r = ChoCSVReader.LoadText(csv)
                .QuoteAllFields()
                .WithFirstLineHeader()
                )
            {
                foreach (var rec in r)
                    Console.WriteLine(rec.Dump());
            }