1

Hi I am very new to C# and have to turn in a module for integration testing tomorrow. I was trying an easy and expidient way to read CSV files and stumbled on ChoETL: https://www.codeproject.com/Articles/1145337/Cinchoo-ETL-CSV-Reader?msg=5847644#xx5847644xx

Following their first example, I tried to run the code:

using ChoETL;
using System;

foreach (dynamic rec in new ChoCSVReader("Emp.csv")
    .WithFirstLineHeader())
{            
    Console.WriteLine($"Id: {rec.Id}");
    Console.WriteLine($"Name: {rec.Name}");
}

When I run it, I get the ouput:

Id: 1
Name: dynamic
Id: 2
Name: dynamic
Id: 3
Name: dynamic

Instead of:

Id: 1
Name: Tom
Id: 2
Name: Carl
Id: 3
Name: Mark

WHy is this? And what is rec being turned to at runtime? I don't know anythnig about dynamic types

I ran this on a Console project on NetCore 5.0 on VS2019

dozie419
  • 13
  • 4

1 Answers1

0

It is bug in the recent package (v1.2.1.30). Alternatively in order to run the sample successfully by doing as below

foreach (dynamic rec in ChoCSVReader.LoadText(csv).WithFirstLineHeader())
{
    Console.WriteLine($"Id: {rec.Id}");
    Console.WriteLine($"Name: " + rec["Name"]);
}

UPDATE:

This issue is fixed and pushed to nuget with v1.2.1.32 and give it try.

Sample fiddle: https://dotnetfiddle.net/REcRCc

Cinchoo
  • 6,088
  • 2
  • 19
  • 34