|
@@ -1,235 +0,0 @@
|
|
|
-
|
|
|
-import csv
|
|
|
-
|
|
|
-import unicodedata
|
|
|
-
|
|
|
-from collections import OrderedDict
|
|
|
-
|
|
|
-import json
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-from datetime import datetime
|
|
|
-
|
|
|
-from random import *
|
|
|
-
|
|
|
-import sys
|
|
|
-
|
|
|
-import json
|
|
|
-
|
|
|
-import_dir = '/Users/alessiaspadi/Documents/RESTORE/temp_MPP/tabelle/Ospedale/mod/'
|
|
|
-export_dir = '/Users/alessiaspadi/Documents/RESTORE/temp_MPP/tabelle/Ospedale/mod/E54_'
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-class RDFcoords:
|
|
|
- def __init__(self, uri, prefix, code = None):
|
|
|
- self.uri = uri
|
|
|
- self.prefix = prefix
|
|
|
- self.code = code
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-museoCoords = RDFcoords('<http://palazzopretorio.comune.prato.it/it/le-opere/alcuni-capolavori/>', 'mpp:')
|
|
|
-
|
|
|
-cidocCoords = RDFcoords('<http://www.cidoc-crm.org/cidoc-crm/>', 'crm:')
|
|
|
-aatCoords = RDFcoords('<http://vocab.getty.edu/aat/>', 'aat:')
|
|
|
-nsCoords = RDFcoords('<http://www.w3.org/1999/02/22-rdf-syntax-ns#>', 'rdf:')
|
|
|
-schemaCoords = RDFcoords('<http://www.w3.org/2000/01/rdf-schema#>', 'rdfs:')
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-def triple(subject, predicate, object1):
|
|
|
- line = subject + ' ' + predicate + ' ' + object1
|
|
|
- return line
|
|
|
-
|
|
|
-def doublet(predicate, object1):
|
|
|
- line = ' ' + predicate + ' ' + object1
|
|
|
- return line
|
|
|
-
|
|
|
-def singlet(object1):
|
|
|
- line = ' ' + object1
|
|
|
- return line
|
|
|
-
|
|
|
-
|
|
|
-continueLine1 = ' ;\n'
|
|
|
-continueLine2 = ' ,\n'
|
|
|
-closeLine = ' .\n'
|
|
|
-
|
|
|
-def writeTTLHeader(output):
|
|
|
- output.write('@prefix ' + museoCoords.prefix + ' ' + museoCoords.uri + closeLine)
|
|
|
- output.write('@prefix ' + cidocCoords.prefix + ' ' + cidocCoords.uri + closeLine)
|
|
|
- output.write('@prefix ' + aatCoords.prefix + ' ' + aatCoords.uri + closeLine)
|
|
|
- output.write('@prefix ' + schemaCoords.prefix + ' ' + schemaCoords.uri + closeLine)
|
|
|
- output.write('@prefix ' + nsCoords.prefix + ' ' + nsCoords.uri + closeLine)
|
|
|
-
|
|
|
- output.write('\n')
|
|
|
-
|
|
|
-
|
|
|
-filePrefix = 'SR20OA_'
|
|
|
-fileType = 'Ospedale'
|
|
|
-max_entries = 1000000000
|
|
|
-
|
|
|
-with open(import_dir + filePrefix + fileType + '.csv', newline="") as csv_file, open(
|
|
|
- export_dir + filePrefix + fileType + '.ttl', 'w') as output:
|
|
|
- reader = csv.DictReader(csv_file)
|
|
|
- writeTTLHeader(output)
|
|
|
- first = True
|
|
|
- ii = 0
|
|
|
- for row in reader:
|
|
|
-
|
|
|
- ii = ii + 1
|
|
|
-
|
|
|
-
|
|
|
- if row['RVEL'] == '' or row['RVEL'] == '0':
|
|
|
-
|
|
|
- codice = ''
|
|
|
- if (row['NCTR'] != '' and row['NCTN'] != ''):
|
|
|
- codice = row['NCTR'] + row['NCTN']
|
|
|
-
|
|
|
- unit = ''
|
|
|
- if (row['MISU'] != ''):
|
|
|
- unit = row['MISU']
|
|
|
-
|
|
|
- valueA = ''
|
|
|
- valueL = ''
|
|
|
-
|
|
|
- if (row['MISA'] != ''):
|
|
|
- value = row['MISA']
|
|
|
- valueA = value.replace(',', 'v')
|
|
|
-
|
|
|
- if (row['MISL'] != ''):
|
|
|
- value = row['MISL']
|
|
|
- valueL = value.replace(',', 'v')
|
|
|
-
|
|
|
- url = row['URL']
|
|
|
-
|
|
|
-
|
|
|
- datplaceHolder = museoCoords.prefix + url
|
|
|
- e55placeHolder = museoCoords.prefix + url + '_E55'
|
|
|
- e58placeHolder = museoCoords.prefix + url + '_unit_' + unit
|
|
|
- e60placeHolderA = museoCoords.prefix + url + '_value_' + valueA
|
|
|
- e60placeHolderL = museoCoords.prefix + url + '_value_' + valueL
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (row['MISA'] != ''):
|
|
|
- line = triple(datplaceHolder,
|
|
|
- cidocCoords.prefix + 'P43_has_dimension',
|
|
|
- museoCoords.prefix + url + '_Altezza') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + url + '_Altezza',
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E54_Dimension') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + url + '_Altezza',
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"Altezza: ' + row['MISA'] + row['MISU'] +'\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
- line = triple(museoCoords.prefix + url + '_Altezza',
|
|
|
- cidocCoords.prefix + 'P90_has_value',
|
|
|
- e60placeHolderA) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e60placeHolderA,
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E60') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e60placeHolderA,
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['MISA'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- line = triple(museoCoords.prefix + url + '_Altezza',
|
|
|
- cidocCoords.prefix + 'P2_has_type',
|
|
|
- aatCoords.prefix + '300055644') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(aatCoords.prefix + '300055644',
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"altezza\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
- if (row['MISU'] != ''):
|
|
|
- line = triple(museoCoords.prefix + url + '_Altezza',
|
|
|
- cidocCoords.prefix + 'P91_has_unit',
|
|
|
- e58placeHolder) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e58placeHolder,
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E58_Measurement_Unit') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e58placeHolder,
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['MISU'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (row['MISL'] != ''):
|
|
|
- line = triple(datplaceHolder,
|
|
|
- cidocCoords.prefix + 'P43_has_dimension',
|
|
|
- museoCoords.prefix + url + '_Larghezza') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + url + '_Larghezza',
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E54_Dimension') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(museoCoords.prefix + url + '_Larghezza',
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"Larghezza: ' + row['MISL'] + row['MISU'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
- line = triple(museoCoords.prefix + url + '_Larghezza',
|
|
|
- cidocCoords.prefix + 'P90_has_value',
|
|
|
- e60placeHolderL) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e60placeHolderL,
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E60') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e60placeHolderL,
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['MISL'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- line = triple(museoCoords.prefix + url + '_Larghezza',
|
|
|
- cidocCoords.prefix + 'P2_has_type',
|
|
|
- aatCoords.prefix + '300055647') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(aatCoords.prefix + '300055647',
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"larghezza\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
- if (row['MISU'] != ''):
|
|
|
- line = triple(museoCoords.prefix + url + '_Larghezza',
|
|
|
- cidocCoords.prefix + 'P91_has_unit',
|
|
|
- e58placeHolder) + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e58placeHolder,
|
|
|
- nsCoords.prefix + 'type',
|
|
|
- cidocCoords.prefix + 'E58_Measurement_Unit') + closeLine
|
|
|
- output.write(line)
|
|
|
- line = triple(e58placeHolder,
|
|
|
- schemaCoords.prefix + 'label',
|
|
|
- '\"' + row['MISU'] + '\"') + closeLine
|
|
|
- output.write(line)
|
|
|
-
|
|
|
-
|
|
|
- output.write('\n')
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if (ii > max_entries):
|
|
|
- break
|