jehugaleahsa / FlatFiles

Reads and writes CSV, fixed-length and other flat file formats with a focus on schema definition, configuration and speed.
The Unlicense
357 stars 64 forks source link

specifying input number style #15

Closed ghost closed 8 years ago

ghost commented 8 years ago

I didn't see anything in the tests, so I'm not sure if is possible or if so how to use it. I have in my csv strings like 12,345.67 and $34.12

I'm curious if FlatFiles can parse these with a specified input formatter

jehugaleahsa commented 8 years ago

If you're working directly with schemas, the numeric columns types provide NumberStyle properties: https://github.com/jehugaleahsa/FlatFiles/blob/master/src/FlatFiles/DecimalColumn.cs#L38. If you're using type mappers, you can use the NumberStyles method: https://github.com/jehugaleahsa/FlatFiles/blob/master/src/FlatFiles/TypeMapping/DecimalPropertyMapping.cs#L31.

Let me know if I misunderstood your question.

On Jul 20, 2016 3:54 PM, "Chris Harrington" notifications@github.com wrote:

I didn't see anything in the tests, so I'm not sure if is possible or if so how to use it. I have in my csv strings like 12,345.67 and $34.12

I'm curious if FlatFiles can parse these with a specified input formatter

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jehugaleahsa/FlatFiles/issues/15, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTgPhX8jVlLktmEFySgws3qTNaWwGIQks5qXn0QgaJpZM4JRJTJ .

ghost commented 8 years ago

I had tried that - using this syntax:

mapper.Property(p => p.Cost).NumberStyles(NumberStyles.Number);

but get a compile error:

"The name 'NumberStyles' does not exist in the current context"

ghost commented 8 years ago

Ah - never mind. I had left out

using System.Globalization;