Class CsvParserFormat

java.lang.Object
com.illumon.iris.db.tables.utils.CsvParserFormat

public class CsvParserFormat extends Object
Returns an Apache CSVFormat based on the fileFormat String.
  • Field Details

  • Constructor Details

    • CsvParserFormat

      public CsvParserFormat()
  • Method Details

    • getFormatNames

      public static String[] getFormatNames()
    • getCsvFormat

      public static org.apache.commons.csv.CSVFormat getCsvFormat(String fileFormat, char delimiter, boolean trim, boolean noHeader, @Nullable List<String> columnNames)
      Returns an Apache CSVFormat based on the fileFormat String.
      Parameters:
      fileFormat - The string for which a format should be created
      delimiter - A single character to use as a delimiter - comma when format will be controlled by fileFormat
      trim - Whether to trim white space within delimiters
      noHeader - Indicates when the CSV does not include a row of column names
      columnNames - A List of column names to use as a header
      Returns:
      A CSVFormat object matching the passed String and trim option
      Throws:
      RuntimeException - if fileFormat is unrecognized
    • getRequiredDelimiter

      public static String getRequiredDelimiter(String fileFormat)
      For the specified file format, return the required delimiter if there is one
      Parameters:
      fileFormat - the file format
      Returns:
      the required delimiter, or null if it is not specified