Get column position of fields from IReaderRow context / GetField #2349
StefanBertels
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When parsing field values I want to use the column position in the row for error messages.
Currently I can only get the row number.
I use this custom method for getting the value (member map):
map.Convert((ConvertFromStringArgs args) => ...)
This means I have an
IReaderRow
context available with.Row
.I can call
.GetField(...)
to get the raw field value (input for my custom parser).My custom parser tells me the error position within raw field value. This error message cannot be used (directly) to find the problem in the file.
Currently I can add the line offset (
args.Row.Parser.Row
) to my parser input context to fix the original error message but this only fixes the line number. Sadly I cannot add the column offset.The required information is internally stored in (non public)
Field
inCsvParser
.Would it be possible to pass this down to user code ("make it public" somehow)?
My use case does not involve line breaks within values but to be consistent maybe there could be variants:
RawColumnByte
(corresponding toRawRow
andbyteCount
)ColumnByte
(corresponding toRow
andbyteCount
)RawColumnChar
(corresponding toRawRow
andcharCount
)ColumnChar
(corresponding toRow
andcharCount
)Maybe
returning a tuple or an interface
IFieldContext(string? Value, int ColumnByte, int ColumnChar ...)
?Beta Was this translation helpful? Give feedback.
All reactions