Access to parsed Tokens data on mapping error
See original GitHub issueThanks for the work done on this library! I’ve been looking at a few options to parse big csv files (2Gb+) and the performance of your implementation is remarkable.
I’m facing an issue now that could be a potential feature enhancement. At the end of the 2Gb files that I am parsing there are “footer” rows that can’t be Mapped to TEntity
but they contain meaningful information on the file.
Parsing the big file once being already time consuming, I’d like to avoid an other full parse.
These lines are being mentioned in the Error collection but their Value is the same for all the footer lines [Column 2 is Out Of Range] and I can’t access the Raw data from there.
One possible fix would be to add a property with the raw data UnmappedRow
to all error lines. I can think of a few other scenarios where a look through the raw data would be handy when an error occurs.
public class CsvMappingError
{
public int ColumnIndex { get; set; }
public string Value { get; set; }
public string UnmappedRow { get; set; }
public override string ToString()
{
return $"CsvMappingError (ColumnIndex = {ColumnIndex}, Value = {Value}, UnmappedRow = {UnmappedRow})";
}
}
And the CsvMapping.cs
could add the raw data to the the Map()
property. Something like:
Error = new CsvMappingError()
{
ColumnIndex = columnIndex,
Value = $"Column {columnIndex} is Out Of Range",
UnmappedRow = string.Join("|", values.Tokens)
}
Alternatively, an UnmappedTokens porperty would also be helpful.
public IEnumerable<string> UnmappedTokens { get; set; }
Thank you
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top GitHub Comments
Thanks for accepting the change and your quick replies!
I have merged the Pull Request. Great, that you also wrote a Unit Test! It may take some time until the evening to build the new NuGet package (it’s 6 am here). Good job. 🤜🤛