summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Aastrand Grimnes <gromgull@gmail.com>2015-10-27 12:11:36 +0100
committerGunnar Aastrand Grimnes <gromgull@gmail.com>2015-10-27 12:13:30 +0100
commitad1ec4e81381175da2c834f9f40e7d0411dbc2c0 (patch)
treec04d14345ffbb8d35888fa5ee945153dff72a782
parent18cce41ed5fdc7e4dc0189fc1107a8afc0e5c258 (diff)
downloadrdflib-ad1ec4e81381175da2c834f9f40e7d0411dbc2c0.tar.gz
fixed a handful of stupid bugs in the csv2rdf tool
-rw-r--r--rdflib/tools/csv2rdf.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/rdflib/tools/csv2rdf.py b/rdflib/tools/csv2rdf.py
index 52dfc6c9..9f785a3b 100644
--- a/rdflib/tools/csv2rdf.py
+++ b/rdflib/tools/csv2rdf.py
@@ -151,7 +151,10 @@ class NodeMaker(object):
class NodeUri(NodeMaker):
def __init__(self, prefix, class_):
self.prefix = prefix
- self.class_ = rdflib.URIRef(class_)
+ if class_:
+ self.class_ = rdflib.URIRef(class_)
+ else:
+ self.class_ = None
def __call__(self, x):
return prefixuri(x, self.prefix, self.class_)
@@ -213,7 +216,7 @@ class NodeSplit(NodeMaker):
def __call__(self, x):
if not self.f:
- f = rdflib.Literal
+ self.f = rdflib.Literal
if not callable(self.f):
raise Exception("Function passed to split is not callable!")
return [
@@ -227,7 +230,7 @@ class NodeSplit(NodeMaker):
default_node_make = NodeMaker()
-def _config_ignore(**args):
+def _config_ignore(*args, **kwargs):
return "ignore"
@@ -328,7 +331,7 @@ class CSV2RDF(object):
# override header properties if some are given
for k, v in self.PROPS.iteritems():
headers[k] = v
- header_labels[k] = split_uri[1]
+ header_labels[k] = split_uri(v)[1]
if self.DEFINECLASS:
# output class/property definitions
@@ -337,7 +340,7 @@ class CSV2RDF(object):
h, l = headers[i], header_labels[i]
if h == "" or l == "":
continue
- if self.COLUMNS.get(i) == "ignore":
+ if self.COLUMNS.get(i) == _config_ignore:
continue
self.triple(h, RDF.type, RDF.Property)
self.triple(h, RDFS.label, rdflib.Literal(toPropertyLabel(l)))
@@ -366,7 +369,7 @@ class CSV2RDF(object):
for i, x in enumerate(l):
x = x.strip()
if x != '':
- if self.COLUMNS.get(i) == "ignore":
+ if self.COLUMNS.get(i) == _config_ignore:
continue
try:
o = self.COLUMNS.get(i, rdflib.Literal)(x)