We have a series of datafiles that are a rectangle of data that someone exports from Excel. Sometimes they export extra columns that are blank entirely. 1, 2, 15. We don't want those columns OR their content, which are nominally empty.
I.E. (pseudo codee)
Our object model
class object "Address" {
Name as string
Street as string
City as string
State as string
Zip as string}
Name, Street, City, State, Zip,,,,,
Bob, Windsor, Chicago, IL, 12342,,,,,
Tom, Second, St Louis, MO, 45122,,,,,
Steve, Main, Nashville, TN, 12124,,,,,
,,,,,,,,,
,,,,,,,,,
,,,,,,,,,
We want the 3 rows of five columns of data. We can add new items to the class for the four "unnecessary" columns, but that doesn't work when the number of those erroneous columns is variable or unknown. When we ignore and continue we get no data. When we don't turn off errors it gets upset when we don't have object class items for those columns.
etc.
We are expecting it to only read columns as we defined in our object model and ignore any extraneous columns
Put an array field at the end of the class and decorate it with
[FieldOptional].Here is a working program: