Search in sources :

Example 1 with ReusableStringReader

use of org.apache.apex.malhar.lib.util.ReusableStringReader in project apex-malhar by apache.

the class DelimitedFSLoader method init.

private void init() {
    delimitedParserSchema = new DelimitedSchema(schema);
    preference = new CsvPreference.Builder(delimitedParserSchema.getQuoteChar(), delimitedParserSchema.getDelimiterChar(), delimitedParserSchema.getLineDelimiter()).build();
    nameMapping = delimitedParserSchema.getFieldNames().toArray(new String[delimitedParserSchema.getFieldNames().size()]);
    header = StringUtils.join(nameMapping, (char) delimitedParserSchema.getDelimiterChar() + "");
    processors = getProcessor(delimitedParserSchema.getFields());
    csvStringReader = new ReusableStringReader();
    csvMapReader = new CsvMapReader(csvStringReader, preference);
}
Also used : DelimitedSchema(org.apache.apex.malhar.contrib.parser.DelimitedSchema) ReusableStringReader(org.apache.apex.malhar.lib.util.ReusableStringReader) CellProcessorBuilder(org.apache.apex.malhar.contrib.parser.CellProcessorBuilder) CsvMapReader(org.supercsv.io.CsvMapReader)

Example 2 with ReusableStringReader

use of org.apache.apex.malhar.lib.util.ReusableStringReader in project apex-malhar by apache.

the class CsvParser method setup.

@Override
public void setup(OperatorContext context) {
    delimitedParserSchema = new DelimitedSchema(schema);
    preference = new CsvPreference.Builder(delimitedParserSchema.getQuoteChar(), delimitedParserSchema.getDelimiterChar(), delimitedParserSchema.getLineDelimiter()).build();
    nameMapping = delimitedParserSchema.getFieldNames().toArray(new String[delimitedParserSchema.getFieldNames().size()]);
    header = StringUtils.join(nameMapping, (char) delimitedParserSchema.getDelimiterChar() + "");
    processors = getProcessor(delimitedParserSchema.getFields());
    csvStringReader = new ReusableStringReader();
    csvMapReader = new CsvMapReader(csvStringReader, preference);
    csvBeanReader = new CsvBeanReader(csvStringReader, preference);
}
Also used : ReusableStringReader(org.apache.apex.malhar.lib.util.ReusableStringReader) CsvBeanReader(org.supercsv.io.CsvBeanReader) CsvMapReader(org.supercsv.io.CsvMapReader)

Aggregations

ReusableStringReader (org.apache.apex.malhar.lib.util.ReusableStringReader)2 CsvMapReader (org.supercsv.io.CsvMapReader)2 CellProcessorBuilder (org.apache.apex.malhar.contrib.parser.CellProcessorBuilder)1 DelimitedSchema (org.apache.apex.malhar.contrib.parser.DelimitedSchema)1 CsvBeanReader (org.supercsv.io.CsvBeanReader)1