How to publish CSV on the Web or why standards are important ODI Friday lecture J. Umbrich, S. Neumaier
CSV
Prominent OD Format
or
Example 1
Example 2
Example 3
Example 4
Example 5
Example 6
CSV on the Web: for humans and machines CSV on the Web publishing CSV for humans and machines
What is CSV? (see RFC4180) RFC4180: C OMMA -S EPARATED V ALUES 1.Each record is separated by a line break 2.The last record may or may not have an ending line break 3.There might be an optional header line 4.Within the header and each record, there may be one ore more fields, separated by commas 5.Each field may or may not be enclosed in double quotes 6.Fields containing line break, double quotes, and commas should be enclosed in double quotes 7.If double-quotes are used to enclose fields, then double-quote appearing inside a field must be escaped 8.file extension:.csvmime-type: text/csv
CSV on the Web is more used as Character-Separated Value files! Most CSV parsers cater for this by using heuristics to identify so called CSV-dialects “CSV” in the wild separator, ; \t line-ending\n \r \r\n quote chars“ ‘
“CSV” on data.gv.at mime-types CSV dialects Anaylsing “CSV “ from data.gv.at CSV-related files:1809 Parsable CSV files:1482 detected a header:1294 delimiter: ';’ 1471 ',’ 9 None 2 #comment lines: >1 67
Example 1
Beilage zum Rechnungsabschluss 2013;;;Nr. 4b; ;;;; NACHWEIS ÜBER DEN SCHULDENDIENST;;;; ;;;; Laut Voranschlag 2013 (inkl. Umbuchungen im Laufe des Jahres) waren für die Abwicklung des Schuldendienstes vorgesehen:;;;; ;;;; für Verzinsung;;; ,00; Zinsreserve gesamt ;;; ,00; für Tilgung;;; ,00; Gesamtvoranschlag;;; ,00; ;;;; Diesem Kredit steht die Jahresvorschreibung von;;; ,01; gegenüber, sodass sich beim gesamten Schuldendienst;;;; eine E i n s p a r u n g von ;;; ,99; ergibt. ;;;; ;;;; Beilage zum Rechnungsabschluss 2013;;;Nr. 4b; ;;;; NACHWEIS ÜBER DEN SCHULDENDIENST;;;; ;;;; Laut Voranschlag 2013 (inkl. Umbuchungen im Laufe des Jahres) waren für die Abwicklung des Schuldendienstes vorgesehen:;;;; ;;;; für Verzinsung;;; ,00; Zinsreserve gesamt ;;; ,00; für Tilgung;;; ,00; Gesamtvoranschlag;;; ,00; ;;;; Diesem Kredit steht die Jahresvorschreibung von;;; ,01; gegenüber, sodass sich beim gesamten Schuldendienst;;;; eine E i n s p a r u n g von ;;; ,99; ergibt. ;;;; ;;;;
Example 1 Beilage zum Rechnungsabschluss 2013;;;Nr. 4b; ;;;; NACHWEIS ÜBER DEN SCHULDENDIENST;;;; ;;;; Laut Voranschlag 2013 (inkl. Umbuchungen im Laufe des Jahres) waren für die Abwicklung des Schuldendienstes vorgesehen:;;;; ;;;; für Verzinsung;;; ,00; Zinsreserve gesamt ;;; ,00; für Tilgung;;; ,00; Gesamtvoranschlag;;; ,00; ;;;; Diesem Kredit steht die Jahresvorschreibung von;;; ,01; gegenüber, sodass sich beim gesamten Schuldendienst;;;; eine E i n s p a r u n g von ;;; ,99; ergibt. ;;;; ;;;; Beilage zum Rechnungsabschluss 2013;;;Nr. 4b; ;;;; NACHWEIS ÜBER DEN SCHULDENDIENST;;;; ;;;; Laut Voranschlag 2013 (inkl. Umbuchungen im Laufe des Jahres) waren für die Abwicklung des Schuldendienstes vorgesehen:;;;; ;;;; für Verzinsung;;; ,00; Zinsreserve gesamt ;;; ,00; für Tilgung;;; ,00; Gesamtvoranschlag;;; ,00; ;;;; Diesem Kredit steht die Jahresvorschreibung von;;; ,01; gegenüber, sodass sich beim gesamten Schuldendienst;;;; eine E i n s p a r u n g von ;;; ,99; ergibt. ;;;; ;;;; ; as separator
Example 1 Beilage zum Rechnungsabschluss 2013;;;Nr. 4b; ;;;; NACHWEIS ÜBER DEN SCHULDENDIENST;;;; ;;;; Laut Voranschlag 2013 (inkl. Umbuchungen im Laufe des Jahres) waren für die Abwicklung des Schuldendienstes vorgesehen:;;;; ;;;; für Verzinsung;;; ,00; Zinsreserve gesamt ;;; ,00; für Tilgung;;; ,00; Gesamtvoranschlag;;; ,00; ;;;; Diesem Kredit steht die Jahresvorschreibung von;;; ,01; gegenüber, sodass sich beim gesamten Schuldendienst;;;; eine E i n s p a r u n g von ;;; ,99; ergibt. ;;;; ;;;; Beilage zum Rechnungsabschluss 2013;;;Nr. 4b; ;;;; NACHWEIS ÜBER DEN SCHULDENDIENST;;;; ;;;; Laut Voranschlag 2013 (inkl. Umbuchungen im Laufe des Jahres) waren für die Abwicklung des Schuldendienstes vorgesehen:;;;; ;;;; für Verzinsung;;; ,00; Zinsreserve gesamt ;;; ,00; für Tilgung;;; ,00; Gesamtvoranschlag;;; ,00; ;;;; Diesem Kredit steht die Jahresvorschreibung von;;; ,01; gegenüber, sodass sich beim gesamten Schuldendienst;;;; eine E i n s p a r u n g von ;;; ,99; ergibt. ;;;; ;;;; ; as separator Not well-formed table empty lines, empty cells headers for column? ; as separator Not well-formed table empty lines, empty cells headers for column?
Example 2
Multiple tables in one file Headers? Multiple tables in one file Headers?
Example 3
Adding computation to the table Meaning of values? Adding computation to the table Meaning of values?
Example 4 All rows have the same length Header available All rows have the same length Header available
Example 4 >>curl -I HTTP/ OK Date: Fri, 27 Nov :35:13 GMT Server: Apache Last-Modified: Fri, 20 Feb :20:48 GMT ETag: "2800c44-2b354-50f80bad05800" Accept-Ranges: bytes Content-Length: Vary: Accept-Encoding Content-Type: text/plain >>curl -I HTTP/ OK Date: Fri, 27 Nov :35:13 GMT Server: Apache Last-Modified: Fri, 20 Feb :20:48 GMT ETag: "2800c44-2b354-50f80bad05800" Accept-Ranges: bytes Content-Length: Vary: Accept-Encoding Content-Type: text/plain HTTP HEADER response
Example 5 All rows have the same length Header available All rows have the same length Header available Comment rows
Example 5: Sex = 1,2,3 ? ? -> Sex = 1,2,3 ? ? ->
Example 6
exhibition_id,city,title,location,datefrom,dateuntil 3,Rom,I LOVE POP,"Chiostro del Bramante, Rom", , ,Krems,Zeitlos - Zur Kunstgeschichte der Zeit,Kunsthalle Krems, , ,"Wien, Österreich",School of London,Kunst Haus Wien, , ,Graz,Die Farben Schwarz,"Landesmuseum Joanneum, Graz", , ,Hamburg,Psyche und Kunst,Universitäts-Krankenhaus Eppendorf, , ,Graz,Michael Schuster,Galerie & Edition Artelier Graz, , ,Prag,Crossings II,Rudolfinum Prag, , ,Köln,"""Kunstwelten im Dialog""","Museum Ludwig, Köln", , Example 6
exhibition_id,city,title,location,datefrom,dateuntil \n 3,Rom,I LOVE POP,"Chiostro del Bramante, Rom", , \n 7,Krems,Zeitlos - Zur Kunstgeschichte der Zeit,Kunsthalle Krems, , \n 8,"Wien, Österreich",School of London,Kunst Haus Wien, , \n 10,Graz,Die Farben Schwarz,"Landesmuseum Joanneum, Graz", , \n 11,Hamburg,Psyche und Kunst,Universitäts-Krankenhaus Eppendorf, , \n 15,Graz,Michael Schuster,Galerie & Edition Artelier Graz, , \n 17,Prag,Crossings II,Rudolfinum Prag, , \n 32,Köln,"""Kunstwelten im Dialog""","Museum Ludwig, Köln", , \n Example 6
exhibition_id,city,title,location,datefrom,dateuntil \n 3,Rom,I LOVE POP,"Chiostro del Bramante, Rom", , \n 7,Krems,Zeitlos - Zur Kunstgeschichte der Zeit,Kunsthalle Krems, , \n 8,"Wien, Österreich",School of London,Kunst Haus Wien, , \n 10,Graz,Die Farben Schwarz,"Landesmuseum Joanneum, Graz", , \n 11,Hamburg,Psyche und Kunst,Universitäts-Krankenhaus Eppendorf, , \n 15,Graz,Michael Schuster,Galerie & Edition Artelier Graz, , \n 17,Prag,Crossings II,Rudolfinum Prag, , \n 32,Köln,"""Kunstwelten im Dialog""","Museum Ludwig, Köln", , \n Example 6
exhibition_id,city,title,location,datefrom,dateuntil \n 3,Rom,I LOVE POP,"Chiostro del Bramante, Rom", , \n 7,Krems,Zeitlos - Zur Kunstgeschichte der Zeit,Kunsthalle Krems, , \n 8,"Wien, Österreich",School of London,Kunst Haus Wien, , \n 10,Graz,Die Farben Schwarz,"Landesmuseum Joanneum, Graz", , \n 11,Hamburg,Psyche und Kunst,Universitäts-Krankenhaus Eppendorf, , \n 15,Graz,Michael Schuster,Galerie & Edition Artelier Graz, , \n 17,Prag,Crossings II,Rudolfinum Prag, , \n 32,Köln,"""Kunstwelten im Dialog""","Museum Ludwig, Köln", , \n Example 6
exhibition_id,city,title,location,datefrom,dateuntil \n 3,Rom,I LOVE POP,"Chiostro del Bramante, Rom", , \n 7,Krems,Zeitlos - Zur Kunstgeschichte der Zeit,Kunsthalle Krems, , \n 8,"Wien, Österreich",School of London,Kunst Haus Wien, , \n 10,Graz,Die Farben Schwarz,"Landesmuseum Joanneum, Graz", , \n 11,Hamburg,Psyche und Kunst,Universitäts-Krankenhaus Eppendorf, , \n 15,Graz,Michael Schuster,Galerie & Edition Artelier Graz, , \n 17,Prag,Crossings II,Rudolfinum Prag, , \n 32,Köln,"""Kunstwelten im Dialog""","Museum Ludwig, Köln", , \n Example 6
exhibition_id,city,title,location,datefrom,dateuntil \n 3,Rom,I LOVE POP,"Chiostro del Bramante, Rom", , \n 7,Krems,Zeitlos - Zur Kunstgeschichte der Zeit,Kunsthalle Krems, , \n 8,"Wien, Österreich",School of London,Kunst Haus Wien, , \n 10,Graz,Die Farben Schwarz,"Landesmuseum Joanneum, Graz", , \n 11,Hamburg,Psyche und Kunst,Universitäts-Krankenhaus Eppendorf, , \n 15,Graz,Michael Schuster,Galerie & Edition Artelier Graz, , \n 17,Prag,Crossings II,Rudolfinum Prag, , \n 32,Köln,"""Kunstwelten im Dialog""","Museum Ludwig, Köln", , \n Example 6
» curl -I HTTP/ OK Date: Thu, 26 Nov :18:47 GMT Server: Apache/ (Debian) Last-Modified: Thu, 26 Nov :03:28 GMT ETag: "6d44-1b fb2450dd" Accept-Ranges: bytes Content-Length: Content-Type: text/csv; charset=utf-8; header=present Link: ;rel=describedBy;type=application/csvm+json » curl -I HTTP/ OK Date: Thu, 26 Nov :18:47 GMT Server: Apache/ (Debian) Last-Modified: Thu, 26 Nov :03:28 GMT ETag: "6d44-1b fb2450dd" Accept-Ranges: bytes Content-Length: Content-Type: text/csv; charset=utf-8; header=present Link: ;rel=describedBy;type=application/csvm+json
Example 6 » curl -I HTTP/ OK Date: Thu, 26 Nov :18:47 GMT Server: Apache/ (Debian) Last-Modified: Thu, 26 Nov :03:28 GMT ETag: "6d44-1b fb2450dd" Accept-Ranges: bytes Content-Length: Content-Type: text/csv; charset=utf-8; header=present Link: ;rel=describedBy;type=application/csvm+json » curl -I HTTP/ OK Date: Thu, 26 Nov :18:47 GMT Server: Apache/ (Debian) Last-Modified: Thu, 26 Nov :03:28 GMT ETag: "6d44-1b fb2450dd" Accept-Ranges: bytes Content-Length: Content-Type: text/csv; charset=utf-8; header=present Link: ;rel=describedBy;type=application/csvm+json Metadata attached to CSV file Allows for a rich “semantic” description of the table and its data Metadata attached to CSV file Allows for a rich “semantic” description of the table and its data
W3C: CSV on the Web Working Group Metadata about tabular data Using JSON format Allows for describing : the CSV dialect, including comments row or multi-header rows, encoding, language, … data types and value ranges for columns primary key and relation to other tables Transformation rules to convert CSV to RDF CSV to JSON
W3C CSV on the Web WG
CSVM Properties
Example CSV Metadata » curl -I HTTP/ OK Date: Thu, 26 Nov :18:47 GMT Server: Apache/ (Debian) Last-Modified: Thu, 26 Nov :03:28 GMT ETag: "6d44-1b fb2450dd" Accept-Ranges: bytes Content-Length: Content-Type: text/csv; charset=utf-8; header=present Link: ;rel=describedBy;type=application/csvm+json » curl -I HTTP/ OK Date: Thu, 26 Nov :18:47 GMT Server: Apache/ (Debian) Last-Modified: Thu, 26 Nov :03:28 GMT ETag: "6d44-1b fb2450dd" Accept-Ranges: bytes Content-Length: Content-Type: text/csv; charset=utf-8; header=present Link: ;rel=describedBy;type=application/csvm+json
Example CSV Metadata { [" "en"}], "url": " "dc:title": "Exhibitions for objects from the mumok collection", "dcat:keyword": ["art", "museum", "exhibition"], "dc:publisher": { "schema:name": "mumok - museum moderner kunst stiftung ludwig wien", "schema:url": " }, "dc:license": " "dc:modified": " ", "xsd:date"}, ….
Example CSV Metadata "dialect": { "encoding": "utf-8", "lineTerminators": ["\r\n", "\n"], "quoteChar": "\"", "doubleQuote": true, "skipRows": 0, "commentPrefix": "#", "header": true, "headerRowCount": 1, "delimiter": ",", "skipColumns": 0, "skipBlankRows": false, "skipInitialSpace": false, "trim": false },
Example CSV Metadata "tableSchema": { "columns": [{ "name": "exhibition_id", "titles": "Exhibition Identifier", "dc:description": "A unique identifier for the exhibition.", "datatype": "integer", "required": true }, { "name": "city", "titles": "City", "dc:description": "The city in which the exhibition took place (no language defined, mostly in German).", "datatype": "string" }, {
How to publish CSV on the WEB Don’t publish CSV on the Web for humans e.g., EXCEL exports RFC 4180 Encoding Use UTF-8, don’t mix encodings File extension:.csv Content-type: text/csv Optional, but big improvement! Ideally, publish CSV MetaData along your CSV file Avoid Acronyms or encodings (e.g., sex=1,2,3)
ADEQUATe Open Data Umfrage Bitte teilnehmen! Das Ziel dieses Fragebogens ist es, Informationen über Open Data Potenziale und Barrieren zu sammeln. Die Umfrage dauert etwa 5 bis 15 Minuten, je nach Ihrer Bereitschaft, auch optionale Fragen zu beantworten.
More information? Please contact us if you have any further questions or need help/support. Stay tuned: !! UI to clean “CSV” files and create/edit metadata Community/Publisher Workshop ? If requested