question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ChoETL CSVWriter is not handling double quotes correctly.

See original GitHub issue

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"

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
Cinchoocommented, Nov 27, 2020

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());
            }
0reactions
liamvinovacommented, Nov 28, 2020

Yeah, it work for me, thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adding double quotes to string while writing to csv c# - ...
So when you add double quotes to the field, CsvHelper recognizes that the whole field needs to be enclosed in double quotes and...
Read more >
Cinchoo ETL - CSV Reader
It is a code based library for extracting data from multiple sources, transforming, and loading into your very own data warehouse in .NET ......
Read more >
Cinchoo ETL – CSV Reader - WordPress.com
This article talks about using CSVReader component offered by ChoETL framework. It is a simple utility class to extract CSV data from file ......
Read more >
To Remove double quotes in CSV file by CSVWriter
Description : Constructs CSVWriter with supplied separator, quote char, escape char and line ending. By default, CSV values are separated by ,.
Read more >
How to read CSV files in C# character ...
If you want to remove all double quotes, simply select the entire worksheet, then go to the Editing group of the Home tab...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found