Interface CsvImporterHelper

All Superinterfaces:
AutoCloseable, Closeable

public interface CsvImporterHelper
extends Closeable
Class to assist with different styles of CSV files
  • Method Summary

    Modifier and Type Method Description
    void close()
    Close the stream
    int getBufferSize()
    Returns the buffer size that will be used when creating a FooterSkipBufferedReader
    List<String> getColumnNamesFromStream()
    Get the list of column names from a CSV file; only call after it's been initialized with a stream
    static CsvImporterHelper getCsvImporterHelper​(String fileFormat, char delimiter, boolean trim, boolean noHeader, int skipHeaderLines, int skipFooterLines, InputStream inputStream, List<String> columnNames)
    Get an appropriate CsvImporterHelper instance
    org.apache.commons.csv.CSVRecord parseNextRecord()
    Parse the next CSV record from the stream
    void setBufferSize​(int bufferSize)
    Sets the buffer size to use for a FooterSkipBufferedReader
    void validateImport()
    Validate the import.
  • Method Details

    • setBufferSize

      void setBufferSize​(int bufferSize)
      Sets the buffer size to use for a FooterSkipBufferedReader
      Parameters:
      bufferSize - size of the buffer in characters
    • getBufferSize

      int getBufferSize()
      Returns the buffer size that will be used when creating a FooterSkipBufferedReader
      Returns:
      int size of the buffer in characters
    • getColumnNamesFromStream

      List<String> getColumnNamesFromStream()
      Get the list of column names from a CSV file; only call after it's been initialized with a stream
      Returns:
      the List of column names
    • parseNextRecord

      org.apache.commons.csv.CSVRecord parseNextRecord() throws IOException
      Parse the next CSV record from the stream
      Returns:
      the parsed CSVRecord
      Throws:
      IOException - if an error occurs
    • close

      void close() throws IOException
      Close the stream
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if an error occurs
    • validateImport

      void validateImport() throws ImportException
      Validate the import.
      Throws:
      ImportException
    • getCsvImporterHelper

      static CsvImporterHelper getCsvImporterHelper​(String fileFormat, char delimiter, boolean trim, boolean noHeader, int skipHeaderLines, int skipFooterLines, InputStream inputStream, List<String> columnNames) throws IOException
      Get an appropriate CsvImporterHelper instance
      Parameters:
      fileFormat - the file format
      delimiter - the delimiter
      trim - whether or not to trim the lines
      noHeader - indicates that the CSV does not contain a header row with column names
      skipHeaderLines - how many lines to skip at the beginning of the data
      skipFooterLines - how many lines to skip at the end of the data
      inputStream - the stream to use for the import
      columnNames - List of column names to use as a header for the CSV. null if no column names are being passed in.
      Returns:
      the app
      Throws:
      IOException