Skip to content

Commit

Permalink
Update addTriplesToRdfFile.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ehanson8 committed Nov 20, 2018
1 parent d6007de commit 4a1b82c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions addTriplesToRdfFile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import csv
from fuzzywuzzy import fuzz
import time
import datetime
import argparse
Expand Down Expand Up @@ -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'])

Expand All @@ -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 != '':
Expand Down Expand Up @@ -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'))
Expand Down

0 comments on commit 4a1b82c

Please sign in to comment.