Skip to content

Commit

Permalink
Empty data cells hold now literals with value 0
Browse files Browse the repository at this point in the history
  • Loading branch information
albertmeronyo committed Jul 2, 2013
1 parent 9eae60d commit df77d3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Empty file modified input/BRT_1889_02_T1_marked.xls 100755 → 100644
Empty file.
17 changes: 11 additions & 6 deletions src/tablinker.py
Expand Up @@ -26,6 +26,7 @@

import sys
reload(sys)
import traceback
sys.setdefaultencoding("latin-1") #@UndefinedVariable


Expand Down Expand Up @@ -351,7 +352,9 @@ def parseSheet(self):
if (self.cellType == 'HRowHeader') :
#Always update headerlist even if it doesn't contain data
self.updateRowHierarchy(i, j)


if self.cellType == 'Data' :
self.parseData(i, j)

if not self.isEmpty(i,j) :
self.graph.add((self.namespaces['scope'][self.source_cell_qname],RDF.type,self.namespaces['d2s'][self.cellType]))
Expand All @@ -376,9 +379,6 @@ def parseSheet(self):

elif self.cellType == 'RowLabel' :
self.parseRowLabel(i, j)

elif self.cellType == 'Data' :
self.parseData(i, j)

self.log.info("Done parsing...")

Expand Down Expand Up @@ -552,7 +552,11 @@ def parseData(self, i,j) :
self.graph.add((self.namespaces['scope'][self.source_cell_qname],self.namespaces['d2s']['isObservation'], observation))
self.graph.add((observation,RDF.type,self.namespaces['qb']['Observation']))
self.graph.add((observation,self.namespaces['qb']['dataSet'],self.namespaces['scope'][self.sheet_qname]))
self.graph.add((observation,self.namespaces['d2s'][self.dataCellPropertyName],Literal(self.source_cell.value)))
if self.isEmpty(i,j):
self.graph.add((observation,self.namespaces['d2s'][self.dataCellPropertyName],Literal(0)))
else:
self.graph.add((observation,self.namespaces['d2s'][self.dataCellPropertyName],Literal(self.source_cell.value)))


# Use the row dimensions dictionary to find the properties that link data values to row headers
try :
Expand Down Expand Up @@ -672,7 +676,7 @@ def parseAnnotation(self, i, j) :
fileWrite = open(turtleFile, "w")
#Avoid rdflib writing the graph itself, as this is buggy in windows.
#Instead, retrieve string and then write (probably more memory intensive...)
turtle = tLinker.graph.serialize(None, format=config.get('general', 'format'))
turtle = tLinker.graph.serialize(destination=None, format=config.get('general', 'format'))
fileWrite.writelines(turtle)
fileWrite.close()

Expand All @@ -687,6 +691,7 @@ def parseAnnotation(self, i, j) :
except :
logging.error("Whoops! Something went wrong in serializing to output file")
logging.info(sys.exc_info())
traceback.print_exc(file=sys.stdout)

logging.info("Done")

Expand Down

0 comments on commit df77d3d

Please sign in to comment.