Csvhelper: 'No header record was found.'

Created on 21 Oct 2017  Â·  3Comments  Â·  Source: JoshClose/CsvHelper

First, let me thank all the contributors to CSVhelper for producing such a useful and well thought out package. However, I am having the following problem:

When I updated to the latest version (v4.0.2) I was unable to read the header record for the CSV files that I was working with, even though this worked well in the previous version.

Below is a test example of the code snippet that I am using to read the header.

using (var FlReader = File.OpenText(@"E:Developement\CSV\CSVtestXLS.csv"))
{
CsvReader csv = new CsvReader(FlReader);
csv.Configuration.HasHeaderRecord = true;

                csv.ReadHeader();
                var myCsv = csv.Context.HeaderRecord;



                }
                csv.Dispose();

Most helpful comment

You need to call Read() first. See ReadHeader here https://joshclose.github.io/CsvHelper/reading#reading-records

All 3 comments

You need to call Read() first. See ReadHeader here https://joshclose.github.io/CsvHelper/reading#reading-records

Hi Mark,

Thank you for quick reply.

Demetrius

[/Volumes/Seagate Backup Plus Drive/Allison/Logos/DirecPathLogo_NoTag_CMYK-01.png]

Demetrius Sotiriades | Reports Analyst

Direct: 414.270.2865 | Fax: 414.271.1795
DirectPathHealth.comhttp://directpathhealth.com/

CONFIDENTIALITY NOTICE: This email communication and any attachments may contain confidential and privileged information for the use of the designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its contents is prohibited. If you have received this communication in error, please notify me immediately by replying to this message and deleting it from your computer.

From: markgould [mailto:[email protected]]
Sent: Saturday, October 21, 2017 2:13 PM
To: JoshClose/CsvHelper CsvHelper@noreply.github.com
Cc: Demetrius Sotiriades dSotiriades@directpathhealth.com; Author author@noreply.github.com
Subject: Re: [JoshClose/CsvHelper] 'No header record was found.' (#808)

You need to call Read() first. See ReadHeader here https://joshclose.github.io/CsvHelper/reading#reading-records

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/JoshClose/CsvHelper/issues/808#issuecomment-338425719, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AfdSFFNAqHnKE_NukWUgPKCYxhMF97Puks5sukI_gaJpZM4QBpJT.

You need to call Read() first. See ReadHeader here https://joshclose.github.io/CsvHelper/reading#reading-records

Landed this issue page through search engine and found the link provided here seems to be broken. Updated link is here for the benefit of future readers https://joshclose.github.io/CsvHelper/examples/reading/reading-by-hand

Was this page helpful?
0 / 5 - 0 ratings