column numbers 0 based line numbers not
A fast, programmer-friendly, free CSV library for Java
Brought to you by:
jamesbassett,
kbg
why are line numbers 1 based and column numbers 0 based. This is very
confusing for users when there are errors.
ex:
column1, column2, column3, column4
line21, line22, line23, line24
line31 line32, , line34
line41, line42 line43, line44
the blank cell is listed in the context as line 3, column 2
Is this a mistake ? lines appear to start at 1 and columns at 0.
You're right, it is a bit confusing. Ideally both line number _and _column
number should start at 1.
I believe the reason that column number starts at zero is that it makes more
sense internally, as:
However, given that the only real purpose of the CsvContext class (which
stores the line/column numbers) is for exceptions, it makes more sense for
column number start at 1 to make it easier for users to find the data that
broke the application.
I've created an issue for this (https://sourceforge.net/tracker/?func=detail&
aid=3493560&group_id=201724&atid=978707) and will include it in
the next release.
Will this make it easier for you?
Cheers,
James
absolutely!
Thank you very much. I was dreading having to modify all exception messages to
keep the column and line numbers clear.
Really appreciate the quick reply!
-Dave
Hi Dave,
This feature is now released with Super CSV 2.0.0-beta-1.
Thanks for the suggestion :)