Class ITER_CSV
java.lang.Object
fr.mines_stetienne.ci.sparql_generate.iterator.IteratorStreamFunctionBase
fr.mines_stetienne.ci.sparql_generate.csv.ITER_CSV
- All Implemented Interfaces:
IteratorFunction
Iterator function
iter:CSV
batch-processes CSV documents, potentially having some custom CSV dialect,
and iteratively binds the content of a selection of cells to the list of
provided variables.
See Live example
The list of parameters is interpreted as follows:- the URI of the CSV document (a URI), or the CSV document itself (a String);
- Optional group of string parameters for custom CSV dialects.
- (boolean: header) true if the CSV has a header row (default is true ).
- (string: quoteChar) the quote character (default is '"' );
- (string: delimiterChar) the delimiter character (default is ',' );
- (string: endOfLineSymbols) the end of line symbol (default is '\n' );
- (integer: batch) Optional number of rows per batch (by default, all the CSV document is processed as one batch);
- (string parameters: names) Names of the columns to select (by default, all the columns are selected).
Examples:
ITERATOR ite:CSV(<path/to/file>) AS ?PersonId ?Namefetches the document having URI <path/to/file> (using the provided jena stream manager); assumes that it has a header row, quote character '"', delimiter character ',', end of line symbol '\n'; processes it in one batch, and binds the cells of the two first column to ?PersonId and ?Name (except for the first column which is the header).ITERATOR ite:CSV("""A1 B1uses the provided CSV document; assumes that it has no header now, uses the provided custom configuration; processes it in one batch, and binds the cells of the two first column to ?A and ?B.
A2 B2""", false, '"', '\t', '\n') AS ?A ?BITERATOR ite:CSV(<path/to/file>, "PersonId", "Name") AS ?PersonId ?Namefetches the document having URI <path/to/file> (using the provided jena stream manager); uses the default configuration; processes it in one batch, and binds the cells of the rows named "PersonId" and "Name" to the corresponding variables.ITERATOR ite:CSV(<path/to/file>, 1000, "PersonId", "Name") AS ?PersonId ?Namefetches the document having URI <path/to/file> (using the provided jena stream manager); uses the default configuration; processes it in batches of 1000 rows, and binds the cells of the rows named "PersonId" and "Name" to the corresponding variables.
- Since:
- 2019-03-23
- Author:
- Maxime Lefrançois
-
Field Summary
FieldsFields inherited from class fr.mines_stetienne.ci.sparql_generate.iterator.IteratorStreamFunctionBase
arguments -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckBuild(org.apache.jena.sparql.expr.ExprList args) Partially checks if the iterator function can be executed with the given arguments.voidexec(List<org.apache.jena.sparql.expr.NodeValue> args, Consumer<List<List<org.apache.jena.sparql.expr.NodeValue>>> collectionListNodeValue) IteratorFunction call to a list of evaluated argument values.Methods inherited from class fr.mines_stetienne.ci.sparql_generate.iterator.IteratorStreamFunctionBase
build, exec, getContext
-
Field Details
-
URI
The SPARQL function URI.- See Also:
-
-
Constructor Details
-
ITER_CSV
public ITER_CSV()
-
-
Method Details
-
exec
public void exec(List<org.apache.jena.sparql.expr.NodeValue> args, Consumer<List<List<org.apache.jena.sparql.expr.NodeValue>>> collectionListNodeValue) Description copied from class:IteratorStreamFunctionBaseIteratorFunction call to a list of evaluated argument values.- Specified by:
execin classIteratorStreamFunctionBase- Parameters:
args- -collectionListNodeValue- - where to emit collections of nodevalues
-
checkBuild
public void checkBuild(org.apache.jena.sparql.expr.ExprList args) Description copied from class:IteratorStreamFunctionBasePartially checks if the iterator function can be executed with the given arguments.- Specified by:
checkBuildin classIteratorStreamFunctionBase- Parameters:
args- -
-