blackmo18 / kotlin-grass

Kotlin Csv to Data Class Parser
Apache License 2.0
38 stars 8 forks source link

Custom transformers #22

Closed cereda closed 3 years ago

cereda commented 3 years ago

Hello!

First of all, thank you very much for this awesome project! I am having a lot of fun with it. :wink:

I would like to suggest a feature: custom transformers.

Background: I have an "interesting" CSV which contains a column (field) holding "booleans". The catch is: they are not described in terms of true and false, but yes and no. I was wondering if grass could include some sort of custom transformers, so one could save post-processing data and skip the use of an intermediate data class. :wink:

Thanks!

blackmo18 commented 3 years ago

@cereda

thanks for appreciation

That's a good idea, tho I would foresee this one the scope would increase, if by design we will not limit the data transfomer from primitive to primitive data type.

Perhanps, do you have a use case where you want it transform to another object?

cereda commented 3 years ago

Hello, sorry for the late comment. :wink:

Yes, I agree the scope would increase. Ultimately, I decided to transform fields within the map returned by the CSV reader, and since I was inside a .map operation anyway, I decided to bite the bullet and transform entries to my data class there.

Perhaps grass could keep the design simple as it is now and, in unusual scenarios like mine, one could resort to direct data manipulation from the CSV reader. So apologies for the noise. :wink:

blackmo18 commented 3 years ago

@cereda Customer Transfomer has been released, see implementation at Java 8 Date Time Support