Menu

column numbers 0 based line numbers not

Help
Anonymous
2012-02-24
2012-09-18
  • Anonymous

    Anonymous - 2012-02-24

    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.

     
  • James Bassett

    James Bassett - 2012-02-25

    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:

    1. The CellProcessor array is zero-based
    2. The data to be read/written is stored in a List (zero-based)

    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

     
  • Anonymous

    Anonymous - 2012-02-25

    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

     
  • James Bassett

    James Bassett - 2012-09-18

    Hi Dave,

    This feature is now released with Super CSV 2.0.0-beta-1.

    Thanks for the suggestion :)