Menu

#330 NoSuchColumnException in CSV.

v2.4.*
closed-fixed
Bug (232)
2.5.0
5
2014-04-20
2012-08-04
No

If the field name has trailing white spaces in CSV header then CsvProducer raises a NoSuchColumnException,

If the header line of your CSV file is one of the following
1 "ID,NAME"
2 " ID,NAME"
3 "ID ,NAME"

then the third one produces a NoSuchColumnException

all it needs to fix it is to replace the line 117 of CsvProducer class
from
columns[i] = new Column((String) readColumns.get(i), DataType.UNKNOWN);
to
columns[i] = new Column(((String) readColumns.get(i)).trim(), DataType.UNKNOWN);

Discussion

  • Jeff Jensen

    Jeff Jensen - 2012-09-30

    Thanks for reporting and providing the fix.
    Commit 1254.
    Would be great if you could provide tests for the method. Refactor it mercilessly; it has too much happening in one method.

     
  • Jeff Jensen

    Jeff Jensen - 2012-09-30
    • status: open --> closed-fixed
     
  • Jeff Jensen

    Jeff Jensen - 2012-09-30
    • assigned_to: gommma --> jeffjensen
     
  • Jeff Jensen

    Jeff Jensen - 2014-04-20
    • Fixed Release: --> 2.5.0
     

Log in to post a comment.