Skip to content

GetRecords<dynamic> Not escaping quotes while GetField() seems to do so? #1845

Answered by JoshClose
Quackers2446 asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not getting that result when reading by hand.

void Main()
{
    var s = new StringBuilder();
    s.Append("name,id\r\n");
    s.Append("\"\"\"Hello\"\", World\", 123\r\n");
    s.Append("Bob,678\r\n");
    var records = new List<Foo>();
    var config = new CsvConfiguration(CultureInfo.InvariantCulture)
    {
    };
    using (var reader = new StringReader(s.ToString()))
    using (var csv = new CsvReader(reader, config))
    {
        csv.Read();
        csv.ReadHeader();
        while (csv.Read())
        {
            var record = new Foo
            {          
                Id = csv.GetField<int>("id"),
                Name = csv.GetField("name"),
            };
            rec…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Quackers2446
Comment options

@JoshClose
Comment options

@Quackers2446
Comment options

Answer selected by Quackers2446
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants