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

Returns headers as list

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.4
    • None
    • Parser
    • None

    Description

      I suggest adding a new method to CSVParser that returns a list of headers. My use case is to create a new CSVPrinter from it that uses different formatting rules.

      My current implementation looks like this:

      Map<String, Integer> headers = parser.getHeaderMap();
      String[] array = new String[headers.size()];
      for (Entry<String, Integer> entry : headers.entrySet()) {
         array[entry.getValue()] = entry.getKey();
      }
      
      CSVFormat outFormat = CSVFormat.newFormat('|').withHeader(array);
      

      This would become a lot simpler, if I could get the (unmodifiable) list directly from CSVParser.

      Attachments

        Activity

          People

            Unassigned Unassigned
            msteiger M. Steiger
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: