From 0d1d2bab034cea0bb63a864cb927af643c04cc04 Mon Sep 17 00:00:00 2001 From: Klaus Rettinghaus Date: Thu, 21 Mar 2019 18:39:01 +0100 Subject: [PATCH 1/2] minor fix for correct id detection --- csv2cmi.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/csv2cmi.py b/csv2cmi.py index 294bc06..6fb1ff8 100755 --- a/csv2cmi.py +++ b/csv2cmi.py @@ -175,7 +175,7 @@ def createCorrespondent(nameString): # assigning authority file IDs to their correspondents if provided if (index < len(personIDs)) and personIDs[index]: # by default complete GND-IDNs to full URI - if 'http://' not in str(personIDs[index].strip()) and str(personIDs[index])[:-2].isdigit(): + if 'http://' not in str(personIDs[index].strip()) and str(personIDs[index].strip())[:-2].isdigit(): logging.debug('Assigning ID %s to GND', str( personIDs[index].strip())) authID = 'http://d-nb.info/gnd/' + \ @@ -563,7 +563,8 @@ def processPlace(letter, correspondent): bibl.text = editionTitle bibl.set('type', editionType) except configparser.NoOptionError: - logging.warning('Incomplete section %s in ini file. Title and type option must be set.', editionKey) + logging.warning( + 'Incomplete section %s in ini file. Title and type option must be set.', editionKey) except configparser.NoSectionError: # if there is no matching section, we assume that there should be no one pass From 2f65309c220dffd659c4ab203aeef7e557d0c441 Mon Sep 17 00:00:00 2001 From: Klaus Rettinghaus Date: Fri, 29 Mar 2019 11:51:48 +0100 Subject: [PATCH 2/2] fix for missing id columns --- csv2cmi.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/csv2cmi.py b/csv2cmi.py index 6fb1ff8..fb18c51 100755 --- a/csv2cmi.py +++ b/csv2cmi.py @@ -159,19 +159,27 @@ def createFileDesc(config): def createCorrespondent(nameString): if letter[nameString]: + defaultElement = 'name' correspondents = [] + personIDs = [] # Turning the cells of correspondent names and their IDs into lists since cells # can contain various correspondents split by an extra delimiter. # In that case it is essential to be able to call each by their index. if subdlm: persons = letter[nameString].split(subdlm) - personIDs = letter[nameString + "ID"].split(subdlm) + try: + personIDs = letter[nameString + "ID"].split(subdlm) + except KeyError: + defaultElement = 'persName' else: - persons = [letter[nameString].strip()] - personIDs = [letter[nameString + "ID"]] + persons = [letter[nameString]] + try: + personIDs = [letter[nameString + "ID"]] + except KeyError: + defaultElement = 'persName' for index, person in enumerate(persons): + correspondent = Element(defaultElement) person = str(person).strip() - correspondent = Element('name') # assigning authority file IDs to their correspondents if provided if (index < len(personIDs)) and personIDs[index]: # by default complete GND-IDNs to full URI