Uploaded image for project: 'Commons CSV'
  1. Commons CSV
  2. CSV-128

CSVFormat.EXCEL should ignore empty header names

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0
    • Fix Version/s: 1.1
    • Component/s: Parser
    • Labels:
      None
    • Environment:

      Description

      I have an Excel file with a first row with N column names
      If there are additional columns that are not labeled, Excel exports empty columns. For example:
      A,B,C,,
      a,b,c,d,e

      This causes an IAE like:

      java.lang.IllegalArgumentException: The header contains a duplicate name: "" in [A, B, C, , ]
      	at org.apache.commons.csv.CSVParser.initializeHeader(CSVParser.java:368)
      	at org.apache.commons.csv.CSVParser.<init>(CSVParser.java:248)
      	at org.apache.commons.csv.CSVParser.parse(CSVParser.java:206)
      

      It seems like the simplest solution is to ignore empty column names, such that they cannot be addressable and not attempt to index them.

        Attachments

          Activity

            People

            • Assignee:
              ggregory Gary D. Gregory
              Reporter:
              ggregory Gary D. Gregory
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: