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

Returns headers as list

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.4
    • Fix Version/s: None
    • Component/s: Parser
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: