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
public class ITER_CSV extends IteratorStreamFunctionBase
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 ?Name
fetches 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 B1
uses 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 ?Name
fetches 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 ?Name
fetches 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
Fields Modifier and Type Field Description static String
URI
The SPARQL function URI.-
Fields inherited from class fr.mines_stetienne.ci.sparql_generate.iterator.IteratorStreamFunctionBase
arguments
-
-
Constructor Summary
Constructors Constructor Description ITER_CSV()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkBuild(ExprList args)
Partially checks if the iterator function can be executed with the given arguments.void
exec(List<NodeValue> args, Consumer<List<List<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 Detail
-
URI
public static final String URI
The SPARQL function URI.- See Also:
- Constant Field Values
-
-
Method Detail
-
exec
public void exec(List<NodeValue> args, Consumer<List<List<NodeValue>>> collectionListNodeValue)
Description copied from class:IteratorStreamFunctionBase
IteratorFunction call to a list of evaluated argument values.- Specified by:
exec
in classIteratorStreamFunctionBase
- Parameters:
args
- -collectionListNodeValue
- - where to emit collections of nodevalues
-
checkBuild
public void checkBuild(ExprList args)
Description copied from class:IteratorStreamFunctionBase
Partially checks if the iterator function can be executed with the given arguments.- Specified by:
checkBuild
in classIteratorStreamFunctionBase
- Parameters:
args
- -
-
-