Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
enridaga committed Feb 7, 2023
1 parent c76f40b commit e767caf
Show file tree
Hide file tree
Showing 19 changed files with 262 additions and 0 deletions.
33 changes: 33 additions & 0 deletions append/README.md
Original file line number Diff line number Diff line change
@@ -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?
16 changes: 16 additions & 0 deletions append/construct.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>

construct {
?subject xyz:key ?key ;
xyz:value ?value .
}
where {
service <x-sparql-anything:> {
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 ) .
}
11 changes: 11 additions & 0 deletions append/count-triples.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>

select count(*)
where {
service <x-sparql-anything:> {
fx:properties fx:location "./out.ttl" .
?a ?b ?c
}
}
12 changes: 12 additions & 0 deletions append/data.json
Original file line number Diff line number Diff line change
@@ -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"}
]
2 changes: 2 additions & 0 deletions append/out-1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
value
A
2 changes: 2 additions & 0 deletions append/out-10.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
value
J
2 changes: 2 additions & 0 deletions append/out-2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
value
B
2 changes: 2 additions & 0 deletions append/out-3.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
value
C
2 changes: 2 additions & 0 deletions append/out-4.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
value
D
2 changes: 2 additions & 0 deletions append/out-5.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
value
E
2 changes: 2 additions & 0 deletions append/out-6.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
value
F
2 changes: 2 additions & 0 deletions append/out-7.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
value
G
2 changes: 2 additions & 0 deletions append/out-8.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
value
H
2 changes: 2 additions & 0 deletions append/out-9.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
value
I
22 changes: 22 additions & 0 deletions append/out.csv
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions append/out.nt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<http://sparql.xyz/facade-x/data/append/5/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/value> "E" .
<http://sparql.xyz/facade-x/data/append/5/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/key> "5"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/10/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/value> "J" .
<http://sparql.xyz/facade-x/data/append/10/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/key> "10"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/3/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/value> "C" .
<http://sparql.xyz/facade-x/data/append/3/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/key> "3"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/6/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/value> "F" .
<http://sparql.xyz/facade-x/data/append/6/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/key> "6"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/8/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/value> "H" .
<http://sparql.xyz/facade-x/data/append/8/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/key> "8"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/1/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/value> "A" .
<http://sparql.xyz/facade-x/data/append/1/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/key> "1"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/4/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/value> "D" .
<http://sparql.xyz/facade-x/data/append/4/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/key> "4"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/7/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/value> "G" .
<http://sparql.xyz/facade-x/data/append/7/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/key> "7"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/9/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/value> "I" .
<http://sparql.xyz/facade-x/data/append/9/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/key> "9"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/2/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/value> "B" .
<http://sparql.xyz/facade-x/data/append/2/2023-02-07T09:20:30.212+00:00> <http://sparql.xyz/facade-x/data/key> "2"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/9/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/value> "I" .
<http://sparql.xyz/facade-x/data/append/9/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/key> "9"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/2/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/value> "B" .
<http://sparql.xyz/facade-x/data/append/2/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/key> "2"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/5/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/value> "E" .
<http://sparql.xyz/facade-x/data/append/5/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/key> "5"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/8/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/value> "H" .
<http://sparql.xyz/facade-x/data/append/8/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/key> "8"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/10/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/value> "J" .
<http://sparql.xyz/facade-x/data/append/10/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/key> "10"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/3/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/value> "C" .
<http://sparql.xyz/facade-x/data/append/3/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/key> "3"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/6/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/value> "F" .
<http://sparql.xyz/facade-x/data/append/6/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/key> "6"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/1/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/value> "A" .
<http://sparql.xyz/facade-x/data/append/1/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/key> "1"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/4/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/value> "D" .
<http://sparql.xyz/facade-x/data/append/4/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/key> "4"^^<http://www.w3.org/2001/XMLSchema#int> .
<http://sparql.xyz/facade-x/data/append/7/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/value> "G" .
<http://sparql.xyz/facade-x/data/append/7/2023-02-07T09:20:32.764+00:00> <http://sparql.xyz/facade-x/data/key> "7"^^<http://www.w3.org/2001/XMLSchema#int> .
86 changes: 86 additions & 0 deletions append/out.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
@prefix fx: <http://sparql.xyz/facade-x/ns/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xyz: <http://sparql.xyz/facade-x/data/> .

<http://sparql.xyz/facade-x/data/append/5/2023-02-07T09:24:22.551+00:00>
xyz:key "5"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "E" .

<http://sparql.xyz/facade-x/data/append/8/2023-02-07T09:24:22.551+00:00>
xyz:key "8"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "H" .

<http://sparql.xyz/facade-x/data/append/10/2023-02-07T09:24:22.551+00:00>
xyz:key "10"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "J" .

<http://sparql.xyz/facade-x/data/append/1/2023-02-07T09:24:22.551+00:00>
xyz:key "1"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "A" .

<http://sparql.xyz/facade-x/data/append/3/2023-02-07T09:24:22.551+00:00>
xyz:key "3"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "C" .

<http://sparql.xyz/facade-x/data/append/6/2023-02-07T09:24:22.551+00:00>
xyz:key "6"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "F" .

<http://sparql.xyz/facade-x/data/append/9/2023-02-07T09:24:22.551+00:00>
xyz:key "9"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "I" .

<http://sparql.xyz/facade-x/data/append/4/2023-02-07T09:24:22.551+00:00>
xyz:key "4"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "D" .

<http://sparql.xyz/facade-x/data/append/7/2023-02-07T09:24:22.551+00:00>
xyz:key "7"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "G" .

<http://sparql.xyz/facade-x/data/append/2/2023-02-07T09:24:22.551+00:00>
xyz:key "2"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "B" .
@prefix fx: <http://sparql.xyz/facade-x/ns/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xyz: <http://sparql.xyz/facade-x/data/> .

<http://sparql.xyz/facade-x/data/append/2/2023-02-07T09:24:38.601+00:00>
xyz:key "2"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "B" .

<http://sparql.xyz/facade-x/data/append/5/2023-02-07T09:24:38.601+00:00>
xyz:key "5"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "E" .

<http://sparql.xyz/facade-x/data/append/10/2023-02-07T09:24:38.601+00:00>
xyz:key "10"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "J" .

<http://sparql.xyz/facade-x/data/append/3/2023-02-07T09:24:38.601+00:00>
xyz:key "3"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "C" .

<http://sparql.xyz/facade-x/data/append/6/2023-02-07T09:24:38.601+00:00>
xyz:key "6"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "F" .

<http://sparql.xyz/facade-x/data/append/8/2023-02-07T09:24:38.601+00:00>
xyz:key "8"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "H" .

<http://sparql.xyz/facade-x/data/append/1/2023-02-07T09:24:38.601+00:00>
xyz:key "1"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "A" .

<http://sparql.xyz/facade-x/data/append/4/2023-02-07T09:24:38.601+00:00>
xyz:key "4"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "D" .

<http://sparql.xyz/facade-x/data/append/7/2023-02-07T09:24:38.601+00:00>
xyz:key "7"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "G" .

<http://sparql.xyz/facade-x/data/append/9/2023-02-07T09:24:38.601+00:00>
xyz:key "9"^^<http://www.w3.org/2001/XMLSchema#int> ;
xyz:value "I" .
11 changes: 11 additions & 0 deletions append/params.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
key
1
2
3
4
5
6
7
8
9
10
11 changes: 11 additions & 0 deletions append/query.sparql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>

select *
where {
service <x-sparql-anything:> {
fx:properties fx:location "./data.json" .
[] xyz:key ?_key_int ; xyz:value ?value .
}
}

0 comments on commit e767caf

Please sign in to comment.