Closed ghost closed 8 years ago
This gave me an idea. I made the changes necessary to associate a preprocessor Func
with a column. Then you could handle your situation like this:
mapper.Property(x => x.SomeValue).Preprocessor(x => x.Trim('"', '='));
Before the value is parsed (to an int
or decimal
), the preprocessor in the example above would remove any leading or trailing quotes ("
) or equal signs (=
).
I created a unit test for you to use as an example: https://github.com/jehugaleahsa/FlatFiles/blob/master/test/FlatFiles.Test/PreprocessorTester.cs#L13.
Perfect!
Some CSV files I get have the syntax:
..., ="12345", ...
The "=" is used force Excel to treat the number as a string when it loads the file. I know that I could pre-process the file to remove all the "=", but I'm interested in seeing what would be involved in modifying FlatFiles to handle that case