Skip column in FileHelper

Using the FileHelper library for .Net, can I somehow skip multiple columns from the source file?

According to the docs and samples, I have to add fields for all columns. Alas, I have an excel sheet with 216 columns for import, of which only 13 are required.

+7
csv filehelpers
source share
2 answers

I have the same situation and question. Searching the forums on filehelpers.net, I found this thread (since 2007!) With the answer of Marcos himself:

Question:

In a layout with length separators, can I skip some fields? For example:
ExternalSysId | ExportDate | FirstName | Lastname
I want only FirstName and LastName and don't want to clutter up my code with dummy fields?

Answer:

There is no built-in function in the library.

You can make fields private, the library will read the values, but you don’t see them from your code =) If you need these fields in the future, you can exchange them publicly.

Thus, using the Record Class Wizard to reduce the amount of input required and then make unnecessary fields private, looks like the best option at this point.

+8
source share

You must add the fields as private and use also the attribute

FieldValueDiscarded

To avoid storing field read values ​​in the library

+2
source share

All Articles