Repository navigation
read-from-std-in silently ignores input unless media-type is provided #641
Copy link
Copy link
Open
Labels
QuestionFurther information is requestedFurther information is requested
Description
Activity
You still need to tell the format as the software is not going to see the file name in this case. Try adding
fx:media-type "text/csv".Example (untested):
PREFIX fx: <http://sparql.xyz/facade-x/ns/> PREFIX xyz: <http://sparql.xyz/facade-x/data/> SELECT ?name ?age { SERVICE <x-sparql-anything:> { fx:properties fx:read-from-std-in "true" ; fx:media-type "text/csv" ; fx:csv.headers "true" . ?row xyz:name ?name ; xyz:age ?age . } }
used as:
printf 'name,age\nVincent,45\nJules,50\n' | sparql-anything -q model.fx
- addedQuestionFurther information is requestedFurther information is requested
on Jul 17, 2026 @enridaga Thanks! and how silly of me.
- But maybe it's better for it to throw an exception rather than silently omitting the content?
- Please fix the doc: the note below the table to this:
- * It is mandatory to provide either `location, content, command` or `read-from-std-in` - * For all except `location` you also need to provide `media-type` so Sparql Anything can interpret the content appropriately- changed the title
[-]`read-from-std-in` doesn't work[/-][+]`read-from-std-in` silently ignores input unless `media-type` is provided[/+]on Jul 20, 2026 - But maybe it's better for it to throw an exception rather than silently omitting the content?
Agreed.
Comment added in doc with d2b971e
Regarding STDIN, I think the default triplifier is the text (without additional params, it just puts the content in a literal):
Without media-type:
$ echo "a,b,c" | java -jar sparql-anything-cli/target/sparql-anything-1.2.0-RC1.jar fx -q "PREFIX fx: <http://sparql.xyz/facade-x/ns/> select * where { service <x-sparql-anything:> {fx:properties fx:read-from-std-in true. ?s ?p ?o }}" s,p,o b0,http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://sparql.xyz/facade-x/ns/root b0,http://www.w3.org/1999/02/22-rdf-syntax-ns#_1,"a,b,c"
With media-type:
$ echo "a,b,c" | java -jar sparql-anything-cli/target/sparql-anything-1.2.0-RC1.jar fx -q "PREFIX fx: <http://sparql.xyz/facade-x/ns/> select * where { service <x-sparql-anything:> {fx:properties fx:read-from-std-in true ; fx:media-type \"text/csv\". ?s ?p ?o }}" s,p,o b0,http://www.w3.org/1999/02/22-rdf-syntax-ns#type,http://sparql.xyz/facade-x/ns/root b0,http://www.w3.org/1999/02/22-rdf-syntax-ns#_1,b1 b1,http://www.w3.org/1999/02/22-rdf-syntax-ns#_1,a b1,http://www.w3.org/1999/02/22-rdf-syntax-ns#_2,b b1,http://www.w3.org/1999/02/22-rdf-syntax-ns#_3,c
What am I doing wrong here?
echo '<urn:x> <urn:p> ("fr" "it")' | \ sparql-anything -q 'construct {?s ?p ?o} where {SERVICE <x-sparql-anything:media-type=text/turtle:read-from-std-in=true> {?s ?p ?o}}' [main] ERROR io.github.sparqlanything.engine.PropertyExtractor - Neither location nor content provided [main] WARN io.github.sparqlanything.engine.FXGraphMaterialisationStrategy - No triplifier found [main] WARN org.apache.jena.sparql.engine.iterator.QueryIteratorCheck - Open iterator [execCxt@2038232668]: QueryIterRoot/0What am I doing wrong here?
echo '<urn:x> <urn:p> ("fr" "it")' | \ sparql-anything -q 'construct {?s ?p ?o} where {SERVICE <x-sparql-anything:media-type=text/turtle:read-from-std-in=true> {?s ?p ?o}}' [main] ERROR io.github.sparqlanything.engine.PropertyExtractor - Neither location nor content provided [main] WARN io.github.sparqlanything.engine.FXGraphMaterialisationStrategy - No triplifier found [main] WARN org.apache.jena.sparql.engine.iterator.QueryIteratorCheck - Open iterator [execCxt@2038232668]: QueryIterRoot/0Use a comma to separate properties via url
x-sparql-anything:media-type=text/turtle,read-from-std-in=trueinstead of
x-sparql-anything:media-type=text/turtle:read-from-std-in=trueHowever, when changing to comma it returns an empty result. There must be something else. Changing to location works:
$ sparql-anything -q 'construct {?s ?p ?o} where {SERVICE <x-sparql-anything:media-type=text/turtle,location=test.ttl> {?s ?p ?o}}' <urn:x> <urn:p> ( "fr" "it" ) .
CSV works as expected:
$ echo 'a,b,c' | \ > sparql-anything -q 'construct {?s ?p ?o} where {SERVICE <x-sparql-anything:media-type=text/csv,read-from-std-in=true> {?s ?p ?o}}' [ a <http://sparql.xyz/facade-x/ns/root>; <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> [ <http://www.w3.org/1999/02/22-rdf-syntax-ns#_1> "a"; <http://www.w3.org/1999/02/22-rdf-syntax-ns#_2> "b"; <http://www.w3.org/1999/02/22-rdf-syntax-ns#_3> "c" ] ] .
So there seems to be something weird happening when reading turtle from stdin.
Metadata
Metadata
Assignees
Labels
QuestionFurther information is requestedFurther information is requested
(Another issue for #636 )
https://sparql-anything.readthedocs.io/stable/Configuration/#general-purpose-options describes
read-from-std-inThe script is
The same script works if I use
fx:location $_locationand pass-v location=enum.csv.The doc has a note below the table that needs to be amended to this: