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 than the columns themselves. The only test is to see if it successfully maps to one of the mapping classes.
I am using CsvHelper with attribute mapping on all my class properties.
csv.GetRecords<T>()
succeeds just fine with the appropriate class for the file and throws an exception (as expected ) when passed an incompatible file and type.
Is there any kind of TryParse
method or technique within CsvHelper that can test to see if a mapping will work, or do I need to build a long nested try {} catch {}
tree and just keep hammering until one of the classes succeeds?
I’ll probably build this out with my own TryGetRecords<T>()
but I wanted to see if there was better or built-in way.