Overview
It is possible to filter out or modify some of the rows in the CSV file before passing the data to the transformation.
The filter can be set when configuring CSV Format.
The technique is explained here.
Available objects and methods
The actual filtering is performed by an object, which can be referenced as a filter
.
The following getters and setters are available for the filter object:
// required import
var javaImports = new JavaImporter(com.toolsverse.etl.connector.text);
with (javaImports) {
// Sets the code which controls the parsing:
// Possible code values:
// TextFilter.TextFilterCode.STOP - stop the parsing
// TextFilter.TextFilterCode.REJECT - skip the line
// TextFilter.TextFilterCode.CONTINUE - continue parsing, default value
filter.setCode(TextFilter.TextFilterCode code);
// Returns current line number.
filter.getIndex();
// Sets the current line number.
filter.setIndex(index);
// Returns current actual line number.
// It is different from line number if Use first Row for Data is enabled
filter.getActualIndex();
// Returns current line.
filter.getLine();
// Sets the current line.
filter.setLine(line);
}
In the example below, we use filter
to:
- Stop parsing a file.
- Skip lines in a file.
if (filter.getActualIndex() == 1) {
filter.setCode(TextFilter.TextFilterCode.REJECT);
filter.setIndex(1);
}
Comments
0 comments
Please sign in to leave a comment.