java.lang.Object
fr.mines_stetienne.ci.sparql_generate.iterator.IteratorStreamFunctionBase
fr.mines_stetienne.ci.sparql_generate.csv.ITER_CSV
All Implemented Interfaces:
fr.mines_stetienne.ci.sparql_generate.iterator.IteratorFunction

public class ITER_CSV extends fr.mines_stetienne.ci.sparql_generate.iterator.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
    A2 B2""", false, '"', '\t', '\n') AS ?A ?B
    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.
  • ITERATOR 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
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
    The SPARQL function URI.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    checkBuild​(org.apache.jena.sparql.expr.ExprList args)
     
    void
    exec​(List<org.apache.jena.sparql.expr.NodeValue> args, Consumer<List<List<org.apache.jena.sparql.expr.NodeValue>>> collectionListNodeValue)
     

    Methods inherited from class fr.mines_stetienne.ci.sparql_generate.iterator.IteratorStreamFunctionBase

    build, exec, getContext

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • 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)
      Specified by:
      exec in class fr.mines_stetienne.ci.sparql_generate.iterator.IteratorStreamFunctionBase
    • checkBuild

      public void checkBuild(org.apache.jena.sparql.expr.ExprList args)
      Specified by:
      checkBuild in class fr.mines_stetienne.ci.sparql_generate.iterator.IteratorStreamFunctionBase