Support SPARQL CSV and TSV output format in REST endpoint
Closed, ResolvedPublic

Description

The export implemented to close https://phabricator.wikimedia.org/T111903 is only available via GUI and it does not conform to http://www.w3.org/TR/sparql11-results-csv-tsv/.

nichtich created this task.Oct 6 2015, 10:48 AM
nichtich updated the task description. (Show Details)
nichtich raised the priority of this task from to Needs Triage.
nichtich added a subscriber: nichtich.
Restricted Application added projects: Wikidata, Discovery. · View Herald TranscriptOct 6 2015, 10:48 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Smalyshev renamed this task from Support SPARQL CSV and TSV output format to Support SPARQL CSV and TSV output format in REST endpoint.Oct 6 2015, 5:11 PM
Smalyshev set Security to None.
Smalyshev added a subscriber: Smalyshev.

@nichtich Could you provide more details about where the noncompliance is?

The export should be available via request parameter format=csv or format=tsv.

CSV export looks fine (e.g. escaping of quotation mark: SELECT * WHERE { wd:Q117929 rdfs:label ?s }). I have not tested whether newlines are handled properly as defined at http://www.w3.org/TR/sparql11-results-csv-tsv/#csv!

TSV export does not conform to http://www.w3.org/TR/sparql11-results-csv-tsv/#tsv. Try for instance SELECT * WHERE { wd:Q1 ?p ?o } LIMIT 4. Expected output:

?p	?o
<http://schema.org/version>	"255220663"
<http://schema.org/dateModified>	"2015-10-06T19:45:26Z"
<http://schema.org/description>	"al die planete, sterre, sterrestelsels en intergalaktiese ruimtes, asook alle energie en materie"@af
<http://schema.org/description>	"\u0645\u0631\u062C\u0639"@ar

instead of

p	o
http://schema.org/version	255220663
http://schema.org/dateModified	2015-10-06T19:45:26Z
http://schema.org/description	al die planete, sterre, sterrestelsels en intergalaktiese ruimtes, asook alle energie en materie
http://schema.org/description	مرجع

I implemented mapping to SPARQL TSV in wdq command line client so you can try expected expected output for a given query (unless I have included a bug):

wdq --query '{wd:Q1 ?p ?o} LIMIT 4' --format tsv

Created T114933 for fixing TSV.

Smalyshev moved this task from Needs triage to WDQS on the Discovery board.Oct 8 2015, 5:10 PM
Smalyshev closed this task as Resolved.Apr 26 2016, 5:31 AM
Smalyshev claimed this task.

Looks like this is already supported if you provide headers: Accept: text/csv or Accept: text/tab-separated-values. TSV export also looks fine to me now.