Skip to content

Commit

Permalink
improved messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rettinghaus committed Oct 13, 2018
2 parents 0e4c539 + 04210f0 commit 947dd76
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
15 changes: 6 additions & 9 deletions README.md
Expand Up @@ -23,21 +23,18 @@ You may provide additional information:
* where a letter has been received: "addresseePlace" (with the appropriate "addresseePlaceID" as proper [GeoNames URL](http://www.geonames.org/))
* when a letter has been received: "addresseeDate"

If your letters are printed across different editions, add an "edition" column and put in there the bibliographic records. Numbering of letters should be stated in a additional column named "key". Alternatively you may enter in this column a link to the edited letter on the web.
Dates have to be entered in ISO format. Limited support for [EDTF](https://www.loc.gov/standards/datetime/pre-submission.html) is implemented to enter uncertain / approximate dates and intervals.
By default only edited letters (i.e. letters with a given edition) are transferred to CMI output. If you want to convert your complete catalogue, use the `-a` option.
The `-n` option allows control whether notes (from a "note" column) will be transferred to the XML.
And with the `--line-numbers` option activated, CSV2CMI will store the line number of each letter in the `n` attribute of `<correspDesc>`.
Furthermore an "edition" column for a bibliographic record, a "key" column for the corresponding number of the edited letter, and even a "note" column can be added.

For sender and addressee IDs from the [GND](http://www.dnb.de/gnd), the [LOC](https://authorities.loc.gov/) and the [VIAF](https://www.viaf.org/) are supported.
Dates have to be entered in ISO format. Limited support for [EDTF](https://www.loc.gov/standards/datetime/pre-submission.html) is implemented to enter uncertain / approximate dates and intervals.

For providing essential CMI information like the editor's name or the publisher an [INI file](https://en.wikipedia.org/wiki/INI_file) is needed.

The output is a minified XML file.


*Check, that your table is using UTF8-encoding!*

For options and further information check the [wiki](https://github.com/saw-leipzig/csv2cmi/wiki).

## License

This program is available under [The MIT License (MIT)](https://opensource.org/licenses/MIT)

__If you use this software, please cite it!__
2 changes: 1 addition & 1 deletion codemeta.json
Expand Up @@ -4,7 +4,7 @@
"identifier": "CSV2CMI",
"name": "CSV2CMI",
"description": "converts a table of letters into CMI format",
"softwareVersion": "1.6.1",
"softwareVersion": "1.6.2",
"license": "OSI Approved :: MIT License",
"programmingLanguage": "Python :: 3",
"maintainer": "https://orcid.org/0000-0003-1898-2543",
Expand Down
19 changes: 12 additions & 7 deletions csv2cmi.py
Expand Up @@ -18,7 +18,7 @@
from xml.etree.ElementTree import Element, SubElement, Comment, ElementTree

__license__ = "MIT"
__version__ = '1.6.1'
__version__ = '1.6.2'

# define log output
logging.basicConfig(format='%(levelname)s: %(message)s')
Expand Down Expand Up @@ -227,20 +227,25 @@ def createCorrespondent(namestring):
if letter[namestring].startswith('[') and letter[namestring].endswith(']'):
correspondent.set('evidence', 'conjecture')
letter[namestring] = letter[namestring][1:-1]
logging.info('Added @evidence for <persName> in line %s',
logging.info('Added @evidence to <%s> from line %s', correspondent.tag,
table.line_num)
correspondent.text = str(letter[namestring])
return correspondent


def createDate(dateString):
date = Element('date')
if dateString.startswith('[') and dateString.endswith(']'):
if '..' in dateString or ',' in dateString:
logging.warning('EDTF One of a set not supported yet')
else:
logging.warning(
'Bracketed uncertain dates are deprecated, please switch to EDTF')
normalized_date = dateString.translate(
dateString.maketrans('', '', '[]()?~%'))
if normalized_date != dateString:
date.set('cert', 'medium')
logging.info(
'Added @cert for <date> in line %s', table.line_num)
logging.info('Added @cert to <date> from line %s', table.line_num)
date_list = normalized_date.split('/')
if len(date_list) == 2:
if checkDatableW3C(date_list[0]):
Expand All @@ -261,15 +266,15 @@ def createPlaceName(placestring):
if letter[placestring].startswith('[') and letter[placestring].endswith(']'):
placeName.set('evidence', 'conjecture')
letter[placestring] = letter[placestring][1:-1]
logging.info('Added @evidence for <placeName> in line %s',
logging.info('Added @evidence to <placeName> from line %s',
table.line_num)
placeName.text = str(letter[placestring])
if (placestring + 'ID' in table.fieldnames) and (letter[placestring + 'ID']):
letter[placestring + 'ID'] = letter[placestring + 'ID'].strip()
if 'http://www.geonames.org/' in letter[placestring + 'ID']:
placeName.set('ref', str(letter[placestring + 'ID']))
else:
logging.warning("No standardized %sID in line %s",
logging.warning('No standardized %sID in line %s',
placestring, table.line_num)
else:
logging.warning('ID for %s missing in line %s', letter[
Expand Down Expand Up @@ -378,7 +383,7 @@ def createID(id_prefix):
entry.set('source', '#' + editionID)
if 'key' in table.fieldnames and letter['key']:
if not(edition):
logging.error("Key without edition in line %s", table.line_num)
logging.error('Key without edition in line %s', table.line_num)
else:
if 'http://' in str(letter['key']):
entry.set('ref', str(letter['key']).strip())
Expand Down
2 changes: 1 addition & 1 deletion example/Example.xml
@@ -1,2 +1,2 @@
<?xml version='1.0' encoding='utf-8'?>
<TEI xmlns="http://www.tei-c.org/ns/1.0"><!--Generated from table of letters with csv2cmi 1.3--><teiHeader><fileDesc><titleStmt><title xml:id="title_o87x8at6_8qmkhm1c">cmi2csv example</title><editor>Klaus Rettinghaus</editor></titleStmt><publicationStmt><publisher>Sächsische Akademie der Wissenschaften zu Leipzig</publisher><idno type="url">https://raw.githubusercontent.com/saw-leipzig/csv2cmi/master/example/Example.xml</idno><date when="2017-06-28T16:44:22.642162" /><availability><licence target="https://creativecommons.org/licenses/by/4.0/">This file is licensed under the terms of the Creative-Commons-License CC-BY 4.0</licence></availability></publicationStmt><sourceDesc><bibl type="print" xml:id="edition_siqs6lya_tkmq7xqs">Bach-Dokumente Bd. 1, Leipzig 1963</bibl></sourceDesc></fileDesc><profileDesc><correspDesc key="23" source="#edition_siqs6lya_tkmq7xqs" xml:id="letter_i8zpz806_djurkht6"><correspAction type="sent" xml:id="sender_kkg5tlzl_2v4wwiau"><persName ref="http://viaf.org/viaf/12304462">Johann Sebastian Bach</persName><placeName ref="http://www.geonames.org/2879139">Leipzig</placeName><date when="1730-10-28" /></correspAction><correspAction type="received" xml:id="addressee_b0w5pp4z_121pygiz"><persName ref="http://viaf.org/viaf/3264804">Georg Erdmann</persName><placeName ref="http://www.geonames.org/3099434">Danzig</placeName></correspAction></correspDesc></profileDesc></teiHeader><text><body><p /></body></text></TEI>
<TEI xmlns="http://www.tei-c.org/ns/1.0"><!-- Generated from table of letters with csv2cmi 1.6.1 --><teiHeader><fileDesc><titleStmt><title xml:id="title_bkp6trec_1eem8c1z">cmi2csv example</title><editor>Klaus Rettinghaus</editor></titleStmt><publicationStmt><publisher>Sächsische Akademie der Wissenschaften zu Leipzig</publisher><idno type="url">https://raw.githubusercontent.com/saw-leipzig/csv2cmi/master/example/Example.xml</idno><date when="2018-10-01T12:32:09.263560" /><availability><licence target="https://creativecommons.org/licenses/by/4.0/">This file is licensed under the terms of the Creative-Commons-License CC-BY 4.0</licence></availability></publicationStmt><sourceDesc><bibl type="print" xml:id="edition_eqa9cmuf_a5nr6j25">Bach-Dokumente Bd. 1, Leipzig 1963</bibl></sourceDesc></fileDesc><profileDesc><correspDesc key="23" source="#edition_eqa9cmuf_a5nr6j25" xml:id="letter_bc408daf_zrv4jz4g"><correspAction type="sent" xml:id="sender_nhser0ic_x6nh2uqb"><persName ref="http://viaf.org/viaf/12304462">Johann Sebastian Bach</persName><placeName ref="http://www.geonames.org/2879139">Leipzig</placeName><date when="1730-10-28" /></correspAction><correspAction type="received" xml:id="addressee_66gvmhv1_lfi91ivi"><persName ref="http://viaf.org/viaf/3264804">Georg Erdmann</persName><placeName ref="http://www.geonames.org/3099434">Danzig</placeName></correspAction><note xml:id="note_l3s423uy_x4hx7iet">four years later</note></correspDesc></profileDesc></teiHeader><text><body><p /></body></text></TEI>

0 comments on commit 947dd76

Please sign in to comment.