From 4a1b82c4f439b82fa50be2367810ee19eea40038 Mon Sep 17 00:00:00 2001 From: ehanson8 Date: Tue, 20 Nov 2018 12:39:24 -0500 Subject: [PATCH] Update addTriplesToRdfFile.py --- addTriplesToRdfFile.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/addTriplesToRdfFile.py b/addTriplesToRdfFile.py index be80390..d2d785c 100644 --- a/addTriplesToRdfFile.py +++ b/addTriplesToRdfFile.py @@ -1,5 +1,4 @@ import csv -from fuzzywuzzy import fuzz import time import datetime import argparse @@ -54,7 +53,7 @@ #set uri starting point uriNum = int(max(uriNums)) -#create log files +#create log file f=csv.writer(open(os.path.join('triplesAdded', rdfFileName[:rdfFileName.index('.')]+'TriplesAdded'+timeStamp+'.csv'),'wb')) f.writerow(['label']+['rdfLabel']+['uri']+['date']) @@ -63,7 +62,7 @@ reader = csv.DictReader(csvfile) for row in reader: altLabel = row['originalLabel'] - prefLabel = row['standardizedLabel'] + prefLabel = row['standardizedLabel'].strip() try: subjectUri = existingLabels[prefLabel] if altLabel != prefLabel and altLabel != '': @@ -102,7 +101,7 @@ q = prepareQuery('SELECT ?s ?prefLabel WHERE { ?s skos:prefLabel ?prefLabel }', initNs = {'skos': SKOS}) results = g.query(q) for row in results: - f.writerow([row[1].encode('utf-8')]+[row[0].encode('utf-8')]) + f.writerow([row[0].encode('utf-8')]+[row[1].encode('utf-8')]) #extract all triples to csv f=csv.writer(open(os.path.join('allTriples','allTriples'+timeStamp+'.csv'),'wb'))