Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple entries in single column #37

Closed
ostelaymetaule opened this issue Jun 9, 2015 · 3 comments
Closed

Multiple entries in single column #37

ostelaymetaule opened this issue Jun 9, 2015 · 3 comments

Comments

@ostelaymetaule
Copy link

Hallo there!
II would like to suggest a new feature.
Assumed there are a csv File with the semicolon as a delimiter. But some of the fields includes multiple values delimited with other signs. Example:

  • Alex;Kovalsky;19.02.2015;50.1
  • john;Smith;04.04.2015:13.02.2014;50.1:16.3
  • Max;Mustermann;;

I would expect such file to be parsed into

first_name:       Alex
last_name:       Kovalsky
Checkout Date: 19.02.2015
Checkout Sum: 50.1
first_name:       john
last_name:       Smith
Checkout Date: 04.04.2015
Checkout Sum: 50.1
first_name:       john
last_name:       Smith
Checkout Date: 13.02.2014
Checkout Sum: 16.3
first_name:       Max
last_name:       Mustermann
Checkout Date: null
Checkout Sum: 0.0

Or with arrays:

first_name:       Alex
last_name:       Kovalsky
Checkout Date[]: {19.02.2015}
Checkout Sum[]: {50.1}
first_name:       john
last_name:       Smith
Checkout Date[]: {04.04.2015, 13.02.2014}
Checkout Sum[]: {50.1, 16.3}
first_name:       Max
last_name:       Mustermann
Checkout Date[]: {}
Checkout Sum[]: {}
@mcavigelli
Copy link
Collaborator

Hello Alexander

I don't think this is a good idea, for several reasons:

  • Filehelpers is thought for "describing a class that maps to each record". With your idea you basically have two classes / records: person and checkout date.
  • Having two delimiters per line will lead to conflicts: what if a name contains a ":". Is that a delimiter or a value? In case of a value, how to escape it?
  • An implementation would be very complicated.

I see two possibilities for your problem:

Do you think any of the approaches would solve your problem?

Matthias

@ostelaymetaule
Copy link
Author

Hello Matthias,
thank you for the answer.
I have solved this with reading the dates and the sum values into string fields and then in the AfterEvent() parse this into list property which is marked with [FieldNotInFile] attribute. myclass has a field defining date and a field defining double. So it looks like dictionary.

So its kinda the first method.
Should i close the issue then?

Best regards,
Alexander

@mcavigelli
Copy link
Collaborator

Hi Alexander

I have not been thinking about a solution with the AfterEvent event.
Congratulations for having solved the problem in such a FileHelper like way.

Matthias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants