FlatMapper icon indicating copy to clipboard operation
FlatMapper copied to clipboard

Custom parsing

Open picasso566 opened this issue 6 years ago • 3 comments

Thanks for the great library.

I am trying to import a fixed width flat file (from COBOL no less) and I need to format some of the fields manually. For instance, the dates are YYYYMMDD. The decimal numeric fields have no placeholders and have a trailing negative like this: 5546 = 55.46, 123450- = (-)1234.50. So I need to manually parse certain fields. The app is in core 2 and I cannot for the life of me figure out how to get a custom formatter working with your code.

.WithMember(o => o.na_dist_dat, set => set.WithLength(8) ) -> "YYYYMMDD" to a datetime

Should I use .WithFormat and implement my own iFormat Provider?

Thanks

picasso566 avatar Apr 16 '18 21:04 picasso566

Hi,

Have you tried the WithMember(o => o-na_dist_dat, set => set.UseValueConverter<ValueConverterType>())

where your ValueConverterType inherits from FieldValueConverter<DateTime>

joaomatossilva avatar Apr 18 '18 16:04 joaomatossilva

I will check into that. In the meantime I moved to FileHelpers (they also have a bunch of handlers for very annoying COBOL text export standards). I much prefer your library so I will see if I can make it work.

picasso566 avatar Apr 18 '18 17:04 picasso566

Thanks for your preference, I do too, but I'm biased 😄

Anyway, that's the good of open source... you have options

joaomatossilva avatar Apr 18 '18 18:04 joaomatossilva