926 questions
-1
votes
0
answers
46
views
CsvHelper - read multiple rows to a single list grouped by a column on CSV [closed]
"Cust1", "CustomerFirstName","CustomerLastName","Street1", "City1","OrderId1","OrderName1"
"Cust1", "...
0
votes
1
answer
27
views
CSVHelper Map available fields
Is there a way to map available fields coming from a CSV file ignoring fields that may not be present in the CSV? For example, I have a class with 5 properties. I want to allow mapping from CSV for ...
0
votes
1
answer
109
views
Character encoding issues while uploading / downloading a CSV to Azure Blob Storage using C#
I have a service which allows users to upload and download a CSV file to update data in a system using C#. This data contains foreign characters. The file appears to upload fine. If I download and ...
0
votes
2
answers
83
views
How to map a nested class by CsvHelper?
class A
{
public C MyC;
public int OtherStuff;
}
class B
{
public C MyC1;
public C MyC2;
}
class C
{
public int WeirdInt;
public string WeirdString;
}
I want to create a ...
1
vote
2
answers
86
views
Write CSV from Nested anonymous object
I didn't succeed to write a CSV for the following structure, I'm pretty sure it should be possible automatically but I'm missing something...
The _recordedData variable is a dictionary of List<...
0
votes
1
answer
92
views
Ignore Comma Delimiter in CsvHelper
I've a project that uses CsvHelper package to parse excel file. Unfortunately I came into a condition where I've to ignore comma as delimiter that CsvHelper does by default I believe. The data in a ...
1
vote
2
answers
107
views
Reading a CSV, modify some field values, writing it back using CsvHelper
I'm using CsvHelper v33.0.1 in a C# program. I'm taking an existing CSV file that contains 70+ columns and about 3000 rows, modifying 3 column values, then rewriting the modified rows back to the ...
-2
votes
2
answers
65
views
What does Format("0.0".PadRight(100, '#') do when writing a CSV with CSVHelper
I have a piece of code I am currently refactoring, but I can't find documentation about what a line in one of the ClassMaps is doing exactly. I try to get rid of the ClassMaps and replace them with ...
1
vote
1
answer
67
views
With CsvHelper, how do I make it use string.Empty instead of Null for missing varchar fields?
Say I have a c# class "Person" with a property named "FirstName". In the database, FirstName is a VARCHAR(100) NOT NULL field. When CsvHelper imports a CSV that lacks a FirstName ...
3
votes
1
answer
96
views
CsvHelper no longer has Context.IsFieldBad
I'm upgrading a program from CsvHelper v2.15.0 to v33.0.1 and dealing with all the changes. I've fixed most of them, but I can't find the solution to this. In my old code I have:
while (csv.Read() &...
0
votes
0
answers
61
views
CsvHelper breaking changes - CsvSerializer
I am upgrading CsvHelper from a very old version (v15). I have this code:
using (var csv = new CsvWriter(new CsvSerializer(output, CultureInfo.CurrentCulture)))
csv.WriteRecords(report);
...
1
vote
1
answer
68
views
CsvHelper passing parameter into map constructor when registering class map
I am using CsvHelper to read a csv file and create a list of records from a file.
I have different types of csv files that contain data to be mapped to the same properties of my models but the headers ...
0
votes
2
answers
92
views
Need help parsing HTML markup with CSVHelper through my .NET API
I receive a CSV from an third party in this format:
Job Requisition Id,Brand,Is Deleted,Internal Status,Job Code,Job Title-JobRequisitionLocale,Posting Start Date-JobRequisitionPosting,Posting End ...
1
vote
1
answer
102
views
CSV Helper - Create Numeric column instead of General
I am using CSV Helper to create a CSV file as follows:
for (int i = 0; i < dsData.Rows.Count; i++)
{
DateTime invDate = Convert.ToDateTime(dsData.Rows[i]["DocDate"].ToString());
...
-1
votes
1
answer
77
views
Write RTL to CSV file using C#
I am trying to write a function that receives a DataTable and writes the data from it into a csv file, The function works, but I want the file content to be displayed in Right-to-Left (RTL)..
I tried ...
1
vote
1
answer
210
views
CsvHelper can't find column header that is not there
I have a project using CsvHelper that I wrote in VS2017 back in 2017, and was working successfully back then. This week I am trying to drag the code into VS2022, .Net Core, and the latest CsvHelper (...
0
votes
1
answer
125
views
Trying Export .csv with CSV Helper in a blazer server app hosted on Azure
I have installed CSV Helper on my Blazer Server App running on Azure using .NET8. When I run the app in my environment it exports to my desktop. When I publish the app and its running on Azure, The ...
0
votes
1
answer
41
views
CSVHelper test parsing against multiple classes with attribute maps
I have a large number of CSV files in multiple formats, all dumped together in one folder. The naming convention is of no use in determining the type, and there is no identifier within the file other ...
0
votes
0
answers
45
views
CSVReader TryGetField Unescaped Quote
I am using CsvReader to parse a string similar to
var dataToParse = "US"|"10"|"0"|"0"|"45.0"|"1.0"|"Product is 1""|"1.65&...
0
votes
2
answers
168
views
Ignore trailing commas in CSV file when using CsvHelper?
I need to read a CSV file with a trailing comma at the end of each line:
column1,column2, // header
value1,value2, // values
Note that the CSV file has only two columns. However the trailing comma ...
0
votes
0
answers
182
views
Using CSVHelper Getting Exceptions with unexpected columns
I am importing data from a 3rd party and only require a few of the fields/columns in the CSV.
The file has the header row:
id created_time ad_id ad_name adset_id adset_name campaign_id ...
-1
votes
1
answer
227
views
CsvHelper.CsvReader won't read CSV file
first things first, my program is supposed to append the contents of a CSV file to an SQL table in SQL Server, using the path put into a text box "pathInputTextBox" and table name from a ...
0
votes
1
answer
46
views
How to mock a configfile
I need to test a function which uses CSVHelper
{
private readonly CsvConfiguration _csvConfig;
public CsvWriterService(CsvConfiguration csvConfig)
{
_csvConfig = csvConfig;
...
-1
votes
1
answer
72
views
How can I use CsvHelper to parse a string into a list of tokens?
I have a C# DLL which already uses CsvHelper to read CSV files. So I was wondering if CsvHelper has the capacity for me to simply pass it a string (not a file) and it return the list of tokens?
So ...
0
votes
0
answers
112
views
How do I handle complex JSON information inside a CSV file?
I´m trying to create an import of CSV data into my Blazor project in .NET7 but I´m facing issues with how to handle the data on one specific field in the CSV and can´t seem to get around the issue.
...
-1
votes
1
answer
91
views
Does CsvHelper GetRecords() actually instantiate objects?
I am using CsvHelper to read data from .csv file.
My code :
var config = new CsvConfiguration(CultureInfo.InvariantCulture){ HasHeaderRecord = true };
using (var textreader = new StreamReader(filepath)...
0
votes
2
answers
375
views
CSVHelper: dynamically write to CSV
Let's say I have the following interface:
public interface IStateInformation
{
public int TaskId { get; set; }
public string Name { get; set; }
}
and the following class implementing this ...
0
votes
1
answer
73
views
How to handle nested delimiter character in fields in CsvHelper?
I'm unable to create a mapping / configuration for the following sample data:
W001;MFS;4262;EMFS;{MFS;W001;;};109;11;"A";["TEID","Int "]
Which should result in something ...
0
votes
0
answers
82
views
CsvReader.Read / CsvReader.ReadAsync duplicates data
Inside an Activity in Azure Durable Functions, I have a method that reads Csv file from certain index. Purpose of this method is to read 2000 rows of the file or until last row, starting from the ...
1
vote
1
answer
59
views
How to add additional columns to CSV in C#
I've created a small C# program to get a CSV file, modify the data, split some line items up, and also add additional columns of data. This last part is introducing errors when run.
Error: Header with ...
0
votes
0
answers
135
views
How to write large data file (csv) to Azure Storage with encryption
I need to implement below in C# (background web job):
Call a stored procedure and get results (rows can be in millions - i.e. 100m so will be implementing pagination to return 500K at a time)
...
0
votes
1
answer
177
views
Blazor component for exporting to csv leaves csv empty
I made a Blazor component which gets a collection of objects and then exports it to csv and download it to the user, the csv is getting downloaded however the output file is empty.
I obtained the code ...
0
votes
0
answers
68
views
Issue: Custom converters are not triggered during CSV file writing with CsvHelper
I'm facing an issue while writing a CSV file using CsvHelper in C#. I have defined some custom converters to handle the conversion of certain data types during writing, however, it seems that these ...
1
vote
1
answer
92
views
CsvReader can not read Request.Body in Asp.net core MVC
CsvReader read stream from Request Body in Asp.net core MVC occured unhandled exception.
■Exception
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware:
Error: An unhandled exception ...
0
votes
2
answers
787
views
How do I replace missing fields in .csv file with default value when the missing field is the last one in the index?
I am trying to use CsvHelper to read a csv file with a few optional properties. Whenever I read the csv, I end up with the error message: CsvHelper.MissingFieldException: Field at index '6' does not ...
0
votes
1
answer
90
views
Importing .csv into DataGridView - various CSV files with different numbers of columns
I would like to ask for your advice. I need to import a .csv file into a DataGridView. I would like the number of columns in the DataGridView to change with each import, depending on the number of ...
0
votes
1
answer
132
views
CsvHelper - Skip rows from csv file arbitrary rows
I have a csv file like this
'some lines to skip : line 1 to 7'
Name,Family,Mobile
'line nine: should be skipped'
'line ten: should be skipped'
A,B,1
C,D,2
How Can I skip first seven lines and third ...
0
votes
1
answer
132
views
How to combine CSVs with different columns?
I have multiple CSV files and I need to combine all of them into 1 CSV file.
So, for example:
1.csv has data like below:
Roll no
Name
1
Abc
2
xyz
2.csv has data like below:
Name
Date
Score
...
0
votes
1
answer
195
views
CSV EnumerateRecords returning same row multiple times in .NET 6
I am using C# console application to read a .CSV file, process it and save the data into a database. While reading the code, I get the correct number of records, but all records are of the last record....
0
votes
2
answers
382
views
Understanding CSV Formatting : Why Common Tools Deviate from RFC 4180 Standards?
I am attempting to parse numerous CSV files (comma-separated, UTF-8 encoding) and have encountered a recurring issue.
Consider a scenario where I have three fields with the values: : A, "B", ...
0
votes
1
answer
184
views
When using CsvHelper with autodetected delimiter, how can you find the delimiter used?
Relates to CsvHelper - https://github.com/JoshClose/CsvHelper
We can use delimiter autodetection when reading a file, but after the reading is complete, is it possible to detect the delimiter used?
I'...
1
vote
1
answer
130
views
How can I add my CSVHelper delimiter to the beginning of each record
I am using CSVHelper to create a pipe delimited file that has dozens of objects that are being mapped and written. The requirement includes having the pipe character at the beginning and end of each ...
2
votes
0
answers
66
views
CSVHelper doesn't store HashSet fields
I'm working on a software project where the program has a data storage and a UI that lets you manipulate this data. I use multiple data types, some of which contain HashSets. I don't do anything ...
0
votes
1
answer
326
views
Unit testing issue with RegisterClassMap in CSVHelper after upgrading CsvHelper from 15.0.5 to 30.0.1
After upgrading CsvHelper, in the unit testing I am getting the
'Can not instantiate proxy of class: CsvHelper.CsvContext.
Could not find a parameterless constructor. (Parameter 'constructorArguments')...
3
votes
1
answer
107
views
CsvHelper throws System.ObjectDisposedException on second iteration
I'm trying to write a method that will read all the CSV files from inside a ZIP file as submitted as an IFormFile through an HttpRequest.
I'm using CsvHelper to read the files contents using this code:...
0
votes
2
answers
638
views
CsvHelper ClassMap constructor parameter, when using Reference<>
I have the following ClassMap:
internal sealed class MyOuterMap : ClassMap<MyOuterClass>
{
public MyOuterMap()
{
References<MyInnerMap>(x => x.MyInnerClassProperty);
...
4
votes
2
answers
580
views
How to create a new CSV file and copy some of columns from old huge CSV file?
I'm a beginner in C#.
I have a huge CSV files with thousands of data(Rows and Columns). With one filter I have created a list called requiredheaders. In this list I took only those header names which ...
1
vote
2
answers
905
views
.NET 4.8 Binding Redirect Guidance
I have a .NET 4.8 Framework WinForms project with the following NuGet packages:
CsvHelper v30.0.1
Microsoft.Extensions.DependencyInjection v7.0.0
I am encountering the following error when running ...
0
votes
1
answer
294
views
DotNet CsvHelper RFC4180 Mode Escape Double Quote
I am parsing a file that contains the following data as part of a line.
12.0000¦6.11000¦LB¦9189AD510001¦Photo Insert 5\" x 5\"Iron¦¦¦23.00¦13.50¦5.00¦IN¦1726.31250¦
I have the following ...
1
vote
0
answers
1k
views
C# MemoryStream and returning a csv file within a controller using CsvHelper [duplicate]
Intended Outcome: From an instance of a specific object (Item) to output the data into a csv file within a API controller.
Approach: To achieve this I have written a class called Item with two ...