Why my csv file doesn't pass the internal CSVHelper test?

0

i'm trying to use CSVHelper inside my project. I created that files:

But after executing the JobApplicationCSV.WriteCSV method i'm getting a CSVHelper Exception:

System.Exception HResult=0x80131500 Nachricht = Header with name 'Company' was not found. If you are expecting some headers to be missing and want to ignore this validation, set the configuration HeaderValidated to null. You can also change the functionality to do something else, like logging the issue. Quelle = latex_curriculum_vitae Stapelüberwachung: at latex_curriculum_vitae.Services.CsvParserService.ReadCsvFileToJobApplicationModel(String path) in C:\Users\Sasch\source\repos\Visual Studio\latex_curriculum_vitae-dotnet\latex_curriculum_vitae\Services\CsvParserService.cs:line 51 at latex_curriculum_vitae.JobApplicationCSV.WriteCSV(String company, String jobtitle, String city, String joburl) in C:\Users\Sasch\source\repos\Visual Studio\latex_curriculum_vitae-dotnet\latex_curriculum_vitae\JobApplicationCSV.cs:line 17 at latex_curriculum_vitae.MainWindow.BtnGenerate_Click(Object sender, EventArgs e) in C:\Users\Sasch\source\repos\Visual Studio\latex_curriculum_vitae-dotnet\latex_curriculum_vitae\MainWindow.xaml.cs:line 106

I pre created a CSV file in path, with the header:

Company,Jobtitle,City,Status,EmailSent,JobOfferUrl

So i actually don't know why it don't passes the test. Maybe i have missed anything?

.net-core
csvhelper
asked on Stack Overflow Oct 5, 2020 by Sascha Manns

1 Answer

2

The version of CsvHelper you are using uses CurrentCulture to get the delimiter. It appears your are in Germany, so your delimiter would be ";" instead of ",". The current version of CsvHelper forces you to pass in a CultureInfo object to CsvReader and CsvWriter with the suggestion of CultureInfo.InvariantCulture to try and mediate this issue.

In your CsvParserService try adding the following to both the ReadCsvFileToJobApplicationModel() and WriteNewCsvFile() methods.

csv.Configuration.Delimiter = ",";
answered on Stack Overflow Oct 5, 2020 by David Specht • edited Oct 5, 2020 by David Specht

User contributions licensed under CC BY-SA 3.0