JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.73k stars 1.06k forks source link

Eliminate the columns if empty #2241

Open sbandaru08 opened 6 months ago

sbandaru08 commented 6 months ago

Is your feature request related to a problem? Please describe. Currently, when working with CSV files using CsvHelper, there isn't a built-in option to automatically eliminate or delete empty columns during the parsing process. This feature would be highly beneficial for users dealing with CSV files containing numerous columns, especially in scenarios where empty columns are not required for data processing or analysis. Describe the solution you'd like I would like to propose the addition of a configuration option or method within CsvHelper that allows users to specify whether empty columns should be eliminated during parsing. Example:

var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
    SkipEmptyColumns = true // or similar configuration option
};

With this enhancement, CsvHelper would intelligently skip or remove empty columns while parsing CSV files, streamlining the data processing workflow and improving overall efficiency.

I believe that implementing this feature would significantly benefit CsvHelper users, making it a more versatile and powerful tool for CSV data manipulation.

Describe alternatives you've considered

Additional context Add any other context or screenshots about the feature request here.

JoshClose commented 6 months ago

I don't understand. You only access the fields that you want to.

mbdaso commented 3 months ago

You can use Optional() in your column mapping to ignore them if they are empty