Menu

#119 Recording input CSV record line number in the mapped bean

v1.0 (example)
wont-fix
None
5
2023-11-10
2023-08-23
KAM
No

Hi,

I am using CsvToBean parser for reading a CSV file which contains named headers. I am interested in recording the input file line number of the record from which target bean is mapped. Is there an option to declare a field in the target bean type and add some annotation which will set the line number? I mean something like annotation @CsvBindByName? Wondering if there is any out of the box support?

Thank you.

Discussion

  • Scott Conway

    Scott Conway - 2023-08-25

    No we currently do not have any sort of annotations for you to use offhand. If you are using an iterator or readNext you can call the getLinesRead() method in the CSVReader and populate the value into the object - https://opencsv.sourceforge.net/apidocs/com/opencsv/CSVReader.html#getLinesRead--

    I typically try and steer people away from that though as we do support multi line data so the value you would be getting is that of the last line for that record.

     
  • Andrew Rucker Jones

    • status: open --> wont-fix
    • assigned_to: Scott Conway
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.