Package com.illumon.iris.importers
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 streamint
getBufferSize()
Returns the buffer size that will be used when creating a FooterSkipBufferedReaderList<String>
getColumnNamesFromStream()
Get the list of column names from a CSV file; only call after it's been initialized with a streamstatic CsvImporterHelper
getCsvImporterHelper(String fileFormat, char delimiter, boolean trim, boolean noHeader, int skipHeaderLines, int skipFooterLines, InputStream inputStream, List<String> columnNames)
Get an appropriate CsvImporterHelper instanceorg.apache.commons.csv.CSVRecord
parseNextRecord()
Parse the next CSV record from the streamvoid
setBufferSize(int bufferSize)
Sets the buffer size to use for a FooterSkipBufferedReadervoid
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
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
Parse the next CSV record from the stream- Returns:
- the parsed CSVRecord
- Throws:
IOException
- if an error occurs
-
close
Close the stream- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an error occurs
-
validateImport
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 IOExceptionGet an appropriate CsvImporterHelper instance- Parameters:
fileFormat
- the file formatdelimiter
- the delimitertrim
- whether or not to trim the linesnoHeader
- indicates that the CSV does not contain a header row with column namesskipHeaderLines
- how many lines to skip at the beginning of the dataskipFooterLines
- how many lines to skip at the end of the datainputStream
- the stream to use for the importcolumnNames
- 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
-