diff --git a/append/README.md b/append/README.md new file mode 100644 index 0000000..987c377 --- /dev/null +++ b/append/README.md @@ -0,0 +1,33 @@ +# append +This parameter tells the command line to now overwrite to an existing file but simply append to it. +Here we test the behaviour in different configurations. + +The following use case works nicely, multiple runs append to the same file: +``` +fx -q construct.sparql -o out.nt --append +fx -q construct.sparql -o out.nt --append +fx -q construct.sparql -o out.nt --append +``` + +This should work with .ttl as well (repeating prefixes should not be an issue): +``` +fx -q construct.sparql -o out.ttl --append +fx -q count-triples.sparql (20) +fx -q construct.sparql -o out.ttl --append +fx -q count-triples.sparql (40) +``` + +This will not work with rdf/xml, json, csv, etc... shall we alert and stop the process when this happens? + +## Interaction with `-v` +In the following case, the system creates a file for each parameter bindings (--append has no effect): +``` +fx -q query.sparql -v params.csv -o out.csv --append + +out-1.csv +out-2.csv +out-3.csv +out-4.csv +... +``` +Question: should we instead append to the same file? \ No newline at end of file diff --git a/append/construct.sparql b/append/construct.sparql new file mode 100644 index 0000000..919652e --- /dev/null +++ b/append/construct.sparql @@ -0,0 +1,16 @@ +PREFIX rdf: +PREFIX xyz: +PREFIX fx: + +construct { + ?subject xyz:key ?key ; + xyz:value ?value . +} +where { + service { + fx:properties fx:location "./data.json" . + [] xyz:key ?_key_int ; xyz:value ?value . + } + BIND (?_key_int as ?key) . + BIND ( fx:entity(xyz:,"append/", ?key , "/" , STR(NOW()) ) as ?subject ) . +} \ No newline at end of file diff --git a/append/count-triples.sparql b/append/count-triples.sparql new file mode 100644 index 0000000..2e6a1ee --- /dev/null +++ b/append/count-triples.sparql @@ -0,0 +1,11 @@ +PREFIX rdf: +PREFIX xyz: +PREFIX fx: + +select count(*) +where { + service { + fx:properties fx:location "./out.ttl" . + ?a ?b ?c + } +} \ No newline at end of file diff --git a/append/data.json b/append/data.json new file mode 100644 index 0000000..e52892e --- /dev/null +++ b/append/data.json @@ -0,0 +1,12 @@ +[ + {"key": 1, "value": "A"}, + {"key": 2, "value": "B"}, + {"key": 3, "value": "C"}, + {"key": 4, "value": "D"}, + {"key": 5, "value": "E"}, + {"key": 6, "value": "F"}, + {"key": 7, "value": "G"}, + {"key": 8, "value": "H"}, + {"key": 9, "value": "I"}, + {"key": 10, "value": "J"} +] \ No newline at end of file diff --git a/append/out-1.csv b/append/out-1.csv new file mode 100644 index 0000000..7603d47 --- /dev/null +++ b/append/out-1.csv @@ -0,0 +1,2 @@ +value +A diff --git a/append/out-10.csv b/append/out-10.csv new file mode 100644 index 0000000..c7c8b2b --- /dev/null +++ b/append/out-10.csv @@ -0,0 +1,2 @@ +value +J diff --git a/append/out-2.csv b/append/out-2.csv new file mode 100644 index 0000000..e8efb9a --- /dev/null +++ b/append/out-2.csv @@ -0,0 +1,2 @@ +value +B diff --git a/append/out-3.csv b/append/out-3.csv new file mode 100644 index 0000000..5a8c3c7 --- /dev/null +++ b/append/out-3.csv @@ -0,0 +1,2 @@ +value +C diff --git a/append/out-4.csv b/append/out-4.csv new file mode 100644 index 0000000..bc393e9 --- /dev/null +++ b/append/out-4.csv @@ -0,0 +1,2 @@ +value +D diff --git a/append/out-5.csv b/append/out-5.csv new file mode 100644 index 0000000..28c582e --- /dev/null +++ b/append/out-5.csv @@ -0,0 +1,2 @@ +value +E diff --git a/append/out-6.csv b/append/out-6.csv new file mode 100644 index 0000000..3737c8c --- /dev/null +++ b/append/out-6.csv @@ -0,0 +1,2 @@ +value +F diff --git a/append/out-7.csv b/append/out-7.csv new file mode 100644 index 0000000..805e4ec --- /dev/null +++ b/append/out-7.csv @@ -0,0 +1,2 @@ +value +G diff --git a/append/out-8.csv b/append/out-8.csv new file mode 100644 index 0000000..47c4080 --- /dev/null +++ b/append/out-8.csv @@ -0,0 +1,2 @@ +value +H diff --git a/append/out-9.csv b/append/out-9.csv new file mode 100644 index 0000000..df2bb79 --- /dev/null +++ b/append/out-9.csv @@ -0,0 +1,2 @@ +value +I diff --git a/append/out.csv b/append/out.csv new file mode 100644 index 0000000..b513e3a --- /dev/null +++ b/append/out.csv @@ -0,0 +1,22 @@ +_key_int,value +2,B +5,E +6,F +4,D +8,H +10,J +9,I +3,C +7,G +1,A +_key_int,value +2,B +5,E +6,F +4,D +8,H +10,J +9,I +3,C +7,G +1,A diff --git a/append/out.nt b/append/out.nt new file mode 100644 index 0000000..8285aca --- /dev/null +++ b/append/out.nt @@ -0,0 +1,40 @@ + "E" . + "5"^^ . + "J" . + "10"^^ . + "C" . + "3"^^ . + "F" . + "6"^^ . + "H" . + "8"^^ . + "A" . + "1"^^ . + "D" . + "4"^^ . + "G" . + "7"^^ . + "I" . + "9"^^ . + "B" . + "2"^^ . + "I" . + "9"^^ . + "B" . + "2"^^ . + "E" . + "5"^^ . + "H" . + "8"^^ . + "J" . + "10"^^ . + "C" . + "3"^^ . + "F" . + "6"^^ . + "A" . + "1"^^ . + "D" . + "4"^^ . + "G" . + "7"^^ . diff --git a/append/out.ttl b/append/out.ttl new file mode 100644 index 0000000..94e40a7 --- /dev/null +++ b/append/out.ttl @@ -0,0 +1,86 @@ +@prefix fx: . +@prefix rdf: . +@prefix xyz: . + + + xyz:key "5"^^ ; + xyz:value "E" . + + + xyz:key "8"^^ ; + xyz:value "H" . + + + xyz:key "10"^^ ; + xyz:value "J" . + + + xyz:key "1"^^ ; + xyz:value "A" . + + + xyz:key "3"^^ ; + xyz:value "C" . + + + xyz:key "6"^^ ; + xyz:value "F" . + + + xyz:key "9"^^ ; + xyz:value "I" . + + + xyz:key "4"^^ ; + xyz:value "D" . + + + xyz:key "7"^^ ; + xyz:value "G" . + + + xyz:key "2"^^ ; + xyz:value "B" . +@prefix fx: . +@prefix rdf: . +@prefix xyz: . + + + xyz:key "2"^^ ; + xyz:value "B" . + + + xyz:key "5"^^ ; + xyz:value "E" . + + + xyz:key "10"^^ ; + xyz:value "J" . + + + xyz:key "3"^^ ; + xyz:value "C" . + + + xyz:key "6"^^ ; + xyz:value "F" . + + + xyz:key "8"^^ ; + xyz:value "H" . + + + xyz:key "1"^^ ; + xyz:value "A" . + + + xyz:key "4"^^ ; + xyz:value "D" . + + + xyz:key "7"^^ ; + xyz:value "G" . + + + xyz:key "9"^^ ; + xyz:value "I" . diff --git a/append/params.csv b/append/params.csv new file mode 100644 index 0000000..09764a2 --- /dev/null +++ b/append/params.csv @@ -0,0 +1,11 @@ +key +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 diff --git a/append/query.sparql b/append/query.sparql new file mode 100644 index 0000000..e5fde28 --- /dev/null +++ b/append/query.sparql @@ -0,0 +1,11 @@ +PREFIX rdf: +PREFIX xyz: +PREFIX fx: + +select * +where { + service { + fx:properties fx:location "./data.json" . + [] xyz:key ?_key_int ; xyz:value ?value . + } +} \ No newline at end of file