public final class CSVHelper extends Object
Modifier and Type | Method and Description |
---|---|
static <R extends OutputRecord> |
createBulkWriteIterator(Iterator<Set<R>> inputIterator,
Map<String,List<String>> fieldNames,
String groupFieldName,
Map<String,OutputStream> ouputStreams) |
static RecordIterator<Record> |
createReadIterator(InputStream inputStream,
String groupFieldName) |
static RecordIterator<Record> |
createReadIterator(InputStream inputStream,
String groupFieldName,
Map<String,String> columnAliasesMap) |
static <R extends Record> |
createWriteIterator(Iterator<R> inputIterator,
List<String> fieldNames,
String groupFieldName,
OutputStream os) |
static List<String> |
getFieldNames(InputStream csvInputStream)
Get the field names from an CSV file provided as an
InputStream . |
static String[] |
parseLine(String line)
Parse a line of a CSV file into an array of
String 's. |
public static RecordIterator<Record> createReadIterator(InputStream inputStream, String groupFieldName, Map<String,String> columnAliasesMap)
groupFieldName
- the name of the group field if anyinputStream
- the CSV input streamcolumnAliasesMap
- a map from column aliases to the actual column namespublic static RecordIterator<Record> createReadIterator(InputStream inputStream, String groupFieldName)
groupFieldName
- the name of the group field if anyinputStream
- the CSV input streampublic static List<String> getFieldNames(InputStream csvInputStream)
InputStream
.csvInputStream
- the CSV input streampublic static String[] parseLine(String line)
String
's.line
- the line to parsepublic static <R extends Record> CloseableIterator<R> createWriteIterator(Iterator<R> inputIterator, List<String> fieldNames, String groupFieldName, OutputStream os)
R
- the type Record
elements passed throughinputIterator
- the input iteratorfieldNames
- the names of the fieldsgroupFieldName
- the name of the group field, if anyos
- the output stream to write topublic static <R extends OutputRecord> CloseableIterator<Set<R>> createBulkWriteIterator(Iterator<Set<R>> inputIterator, Map<String,List<String>> fieldNames, String groupFieldName, Map<String,OutputStream> ouputStreams)
R
- the type Record
elements passed throughinputIterator
- the input iteratorfieldNames
- the names of the fieldsgroupFieldName
- the name of the group field, if anyouputStreams
- the output streams to write toCopyright © 2005–2016 Zementis, Inc.. All rights reserved.