# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['triplify_csv']

package_data = \
{'': ['*']}

install_requires = \
['click>=8.0.3,<9.0.0', 'pytest>=6.2.5,<7.0.0', 'rdflib>=6.0.2,<7.0.0']

entry_points = \
{'console_scripts': ['triplify_csv = triplify_csv.triplify_csv:process']}

setup_kwargs = {
    'name': 'triplify-csv',
    'version': '0.1.0',
    'description': 'A tool to generate triples from CSV files according to a configuration file.',
    'long_description': '============\ntriplify_csv\n============\nFeatures\n--------\nGenerates RDF triples or quads in Turtle or NQuad syntax from one or more CSV files and a configuration file.\n\nInstallation\n------------\ntriplify_csv can be installed from PyPI using \'pip\':\n\n.. code-block:: bash\n\n\tpip install triplify_csv\n\n\nUsage\n-----\ntriplify_csv installs as both a package and command line interface tool\n\n**Example of using the package**\n\n.. code-block:: python\n\n\tfrom TriplifyCsv import Rml, CsvOptions\n\t\n\t# config mapping files are .ttl files\n\tconfigfile = \'myconfig.ttl\'\n\t\n\t# csv files should be .csv files\n\tcsvfile1, csvfile2 = \'mycsv1.csv\', \'mycsv2.csv\'\n\t\n\t# output file must have either a .ttl extension for turtle triples \n\t# or a .nq extension for quads\n\toutputfile = \'mytriples.ttl\'\n\t\n\trml = Rml()\n\t\n\t# default date format of dates in your CSV files is \'%Y-%m-%d\'\n\t# default csv delimiter is \',\'\n\t# override the defaults by setting options\n\toptions = CsvOptions(dateformat=\'%d/%m/%Y\', delimiter=\'|\')\n\t\n\t# load one rml and one or more csvs\n\trml.loadFile(configfile, [csvfile1,csvfile2], options)\n\t\n\trml.create_triples()\n\t\n\t# "nquads" for named graphs need a .nq extension\n\t# here we are generating triples so .ttl for turtle syntax\n\trml.write_file(outputfile, format="ttl")\n\t \n\n**Example of CLI use - help text**\n\nTo display full help text on the options enter the following at the command line\n\n.. code-block:: bash\n\t\n\ttriplify_csv --help\n\t \n\n**Example of CLI use - making triples**\nThe same example as the one in code above as a CLI call instead ...\n\n.. code-block:: bash\n\t\n\ttriplify_csv -m \'myconfig.ttl\' -c \'mycsv1.csv\' -c \'mycsv2.csv\' -o \'mytriples.ttl\'\n\t \n**How to make your configuration file**\n\nThe configuration file contains a set of mappings for triplify_csv to follow to set the subjects, predicates and objects or literal values of your triples or nquads from the data in one or more CSV files. These mappings are RDF triples in the turtle syntax.  The terms that can be used are a subset of the terms defined in the R2RML standard.  \n\nR2RML was not designed for this purpose. R2RML is \'.. a language for expressing customized mappings from relational databases to RDF datasets.\' (see https://www.w3.org/TR/r2rml/ ). Triplify_csv uses a subset of R2RML to express customised mappings from CSV files to RDF datasets.  Where R2RML refers to the tables of a database using \'rr:logicalTable\' this should be understood in the triplify_csv use of R2RML as referring to the name (without \'.csv\') of a corresponding csv file.  \'rr:sqlQuery\', the term of the R2RML language that lets you express mappings from database queries to RDF isn\'t supported in the triplify_csv usage.  Also, there is no need to support \'rr:sqlVersion\'.\n\nFor a complete list of what parts of the R2RML language are supported see the examples in the /tests folder and refer to the R2RML test cases document (https://www.w3.org/TR/rdb2rdf-test-cases/). As of version 0.1.0 the test cases supported are\n\n- R2RMLTC0007a - Typing resources by relying on rdf:type predicate\n- R2RMLTC0007b - Assigning triples to Named Graphs\n- R2RMLTC0007c - One column mapping, using rr:class\n- R2RMLTC0007d - One column mapping, specifying an rr:predicateObjectMap with rdf:type\n- R2RMLTC0007e - One column mapping, using rr:graphMap and rr:class\n- R2RMLTC0007f - One column mapping, using rr:graphMap and specifying an rr:predicateObjectMap with rdf:type\n- R2RMLTC0007g - Assigning triples to the default graph\n- R2RMLTC0007h - Assigning triples to a non-IRI named graph\n- R2RMLTC0008a - Generation of triples to a target graph by using rr:graphMap and rr:template\n- R2RMLTC0008b - Generation of triples referencing object map\n- R2RMLTC0008c - Generation of triples by using multiple predicateMaps within a rr:predicateObjectMap\n- R2RMLTC0009a - Generation of triples from foreign key relations\n\n\n**Simple config file example**\nSuppose you have a CSV file containing details of contacts (example format below) and you want to generate RDF data from this using FOAF as the ontology you want to make use of for this, the R2RML config file might look like this ...\n\n.. code-block:: bash\n\n\t@prefix rr: <http://www.w3.org/ns/r2rml#> .\n\t@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n\t@prefix ex: <http://example.com/> .\n\t@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\t@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n\t@base <http://example.com/base/> .\n\t\n\t<TriplesMap1> a rr:TriplesMap;\n\trr:logicalTable [ rr:tableName "\\"Contacts\\"" ];\n\t\n\trr:subjectMap [ rr:template "http://example.com/Contact/{\\"ID\\"}/{\\"Name\\"}";\n\t rr:class foaf:Person;\n\t];\n\t\n\trr:predicateObjectMap [ rr:predicate ex:id ;\n\t rr:objectMap [ rr:column "\\"ID\\"" ;  ] ;\n\t];\n\t\n\trr:predicateObjectMap [ rr:predicate foaf:name ;\n\t rr:objectMap [ rr:column "\\"Name\\"" ; ] ;\n\t];\n\t\n\trr:predicateObjectMap [ rr:predicate foaf:interest ;\n\t  rr:objectMap [ rr:column "\\"Interest\\"" ; ] ;\n\t];\n\t\n\t.\n\n\n\n\nCreate a CSV file called \'Contacts.csv\' using commas as delimiters between the following values (shown here in a table) ...\n\n.. csv-table:: Contacts.csv\n\t:header: "ID", "Name", "Interest"\n\t:widths: auto\n\n\t10, "John Smith", https://en.m.wikipedia.org/wiki/Tennis\n\t20, "Joe Bloggs", https://en.m.wikipedia.org/wiki/Golf\n\t30, "Mr Bun", https://en.m.wikipedia.org/wiki/Spam_(food)\n\n\nNow, with triplify_csv installed save the R2RML config file as \'contactsmap.ttl\' and the csv file as \'Contacts.csv\' and generate the output containing your triples to a file called \'contactstriples.ttl\' (for example) with the following command ...\n\n.. code-block:: bash\n\t\n\ttriplify_csv -m \'contactsmap.ttl\' -c \'Contacts.csv\' -o \'contactstriples.ttl\'\n\n\t\nThe resulting triples in turtle syntax in the \'contactstriples.ttl\' file\nwould look like this ...\n\n.. code-block:: bash\n\n\t@prefix ex: <http://example.com/> .\n\t@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n\t@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n\t\n\t<http://example.com/Contact/10/John%20Smith> a foaf:Person ;\n\t    ex:id 10 ;\n\t    foaf:interest "https://en.m.wikipedia.org/wiki/Tennis" ;\n\t    foaf:name "John Smith" .\n\t\n\t<http://example.com/Contact/20/Joe%20Bloggs> a foaf:Person ;\n\t    ex:id 20 ;\n\t    foaf:interest "https://en.m.wikipedia.org/wiki/Golf" ;\n\t    foaf:name "Joe Bloggs" .\n\t\n\t<http://example.com/Contact/30/Mr%20Bun> a foaf:Person ;\n\t    ex:id 30 ;\n\t    foaf:interest "https://en.m.wikipedia.org/wiki/Spam_(food)" ;\n\t    foaf:name "Mr Bun" .\n',
    'author': 'Adrian Atley',
    'author_email': None,
    'maintainer': None,
    'maintainer_email': None,
    'url': None,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.7,<4.0',
}


setup(**setup_kwargs)
