Replies: 5 comments
-
@Mohakalilam Could you post a code sample that reproduces this issue? |
Beta Was this translation helpful? Give feedback.
-
using (var reader = new StreamReader(@"I:\FWorks\PropertyTax\AnokaCty.csv"))
using (var csv = new CsvReader(reader))
{
csv.Configuration.PrepareHeaderForMatch = (string header, int index) => Regex.Replace(header, @"\s", string.Empty);
csv.Configuration.HasHeaderRecord = true;
csv.Configuration.RegisterClassMap<OwnerMap>();
//csv.ReadAsync();
//csv.ReadHeader();
Owners = csv.GetRecords<Owner>().ToList();
using (var dr = new CsvDataReader(csv))
{
var dt = new DataTable();
dt.Load(dr);
}
} Also , I dont get the header using the ReadHeader , and so I had to comment those lines and I got the Records successfully. But now the issue is with datatable. |
Beta Was this translation helpful? Give feedback.
-
Can you give the header row and the first data row? What is the issue with How are you using the attributes? |
Beta Was this translation helpful? Give feedback.
-
Here is my header row OwnerFirstName | OwnerLastName | PropAddress | PropCity | PropState | PropZip | MailingAddress | MailingCity | MailingState | MailingZip | Property County | CumulativeDue The issue with datatable is that it returns null although I am able to get ercord using GetRecords(). |
Beta Was this translation helpful? Give feedback.
-
@Mohakalilam This happens because you are consuming the whole file with your call to If you want to read the same stream again, you'll have to reset it, and create a new instance of your CsvReader (just to be safe, in case it does any kind of caching now or in future versions).
Out of curiosity, why are you loading the CSV file twice? And why do you need to load into a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I can the records mapped with my header in the file, but while creating datatable, csvDataReader says "No header found".
Any idea?
Beta Was this translation helpful? Give feedback.
All reactions