Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional record type with FileHelpers [closed]

I'm trying to parse a file using the Filehelpers library. My file looks like this:

000001,"A",123,456
000002,"B","ABC","XYZ"
000003,"B","DEF","XYZ"
000004,"B","HIJ","XYZ"

My file contains rows that have different column definitions, where the 'type' of row is defined by the character in the second column. i.e. In the sample above I have an "A" row followed by three "B" rows.

Filehelpers requires that I pass the CLR type used to define a row when I instantiate the file helpers engine, or us the generic version as below.

FileHelperEngine<ARecord> engine = new FileHelperEngine<ARecord>()

This means I'm restricted to a single type to define every row in my file. Is there any way I can parse a file like this and conditionally specify the record type based on a part of the given row?

like image 281
Dav Evans Avatar asked Apr 08 '26 21:04

Dav Evans


1 Answers

found it. http://www.filehelpers.com/example_multirecords.html

like image 165
Dav Evans Avatar answered Apr 11 '26 11:04

Dav Evans