Extrahieren der ID-Daten aus allen Fragen
This commit is contained in:
parent
cc6a42970e
commit
2afa416253
2 changed files with 58 additions and 14 deletions
|
|
@ -61,7 +61,7 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1684368494840" FOLDED="true" ID="ID_1680262238" MODIFIED="1684448582270" POSITION="right" TEXT="Vor-Analyse (Hermann)">
|
||||
<node COLOR="#338800" CREATED="1684368494840" ID="ID_1680262238" MODIFIED="1684521702053" POSITION="right" TEXT="Vor-Analyse (Hermann)">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1684377232205" ID="ID_1958647529" MODIFIED="1684377240495" TEXT="Word-Dokument">
|
||||
<node COLOR="#435e98" CREATED="1684377241659" ID="ID_211996471" MODIFIED="1684438272776" TEXT="Analyse">
|
||||
|
|
@ -195,7 +195,8 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1684425204543" ID="ID_1966384514" MODIFIED="1684425539402" TEXT="Lösungs-Skizze">
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1684425204543" FOLDED="true" ID="ID_1966384514" MODIFIED="1684521722151" TEXT="Lösungs-Skizze">
|
||||
<linktarget COLOR="#a9b4c1" DESTINATION="ID_1966384514" ENDARROW="Default" ENDINCLINATION="-105;-9;" ID="Arrow_ID_1306849550" SOURCE="ID_676425093" STARTARROW="None" STARTINCLINATION="-105;-9;"/>
|
||||
<icon BUILTIN="idea"/>
|
||||
<node CREATED="1684425212214" ID="ID_371250010" MODIFIED="1684425279954" TEXT="SoSci-Definitionen einlesen">
|
||||
<icon BUILTIN="full-1"/>
|
||||
|
|
@ -224,10 +225,42 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1684368507446" ID="ID_1735162824" MODIFIED="1684368541488" POSITION="right" TEXT="Python-Skript">
|
||||
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1684368507446" ID="ID_1735162824" MODIFIED="1684521700693" POSITION="right" TEXT="Python-Skript">
|
||||
<icon BUILTIN="hourglass"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1684368529445" ID="ID_676425093" MODIFIED="1684368539206" TEXT="Implementierung">
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1684368529445" ID="ID_676425093" MODIFIED="1684521720351" TEXT="Implementierung">
|
||||
<arrowlink DESTINATION="ID_1966384514" ENDARROW="Default" ENDINCLINATION="-105;-9;" ID="Arrow_ID_1306849550" STARTARROW="None" STARTINCLINATION="-105;-9;"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1684425212214" ID="ID_426224894" MODIFIED="1684524018933" TEXT="SoSci-Definitionen einlesen">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1684425286586" ID="ID_1263838545" MODIFIED="1684524021048" TEXT="alle <question>-Elemente aufsammeln">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node COLOR="#338800" CREATED="1684425304928" ID="ID_775756785" MODIFIED="1684524225358" TEXT="per Kontext die vollständige ID ablegen">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1684425317985" ID="ID_773218424" MODIFIED="1684425326800" TEXT="daraus ein polymorphes Python-Objekt generieren"/>
|
||||
<node CREATED="1684425327278" ID="ID_1210419956" MODIFIED="1684425420316" TEXT="dies in eine Map-keyed-by-ID ablegen">
|
||||
<arrowlink DESTINATION="ID_960847395" ENDARROW="Default" ENDINCLINATION="187;0;" ID="Arrow_ID_184243819" STARTARROW="None" STARTINCLINATION="187;0;"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1684425234772" ID="ID_829734331" MODIFIED="1684521730288" TEXT="SoSci-Questionaire verarbeiten">
|
||||
<icon BUILTIN="full-2"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1684425355743" ID="ID_336090024" MODIFIED="1684425365214" TEXT="das nested XML extrahieren und parsen"/>
|
||||
<node CREATED="1684425365798" ID="ID_1030356083" MODIFIED="1684425376845" TEXT="die Seitenstruktur navigieren"/>
|
||||
<node CREATED="1684425378039" ID="ID_960847395" MODIFIED="1684425420299" TEXT="jedes konkret referenzierte Block-Element aus der Map holen">
|
||||
<linktarget COLOR="#a9b4c1" DESTINATION="ID_960847395" ENDARROW="Default" ENDINCLINATION="187;0;" ID="Arrow_ID_184243819" SOURCE="ID_1210419956" STARTARROW="None" STARTINCLINATION="187;0;"/>
|
||||
</node>
|
||||
<node CREATED="1684425424682" ID="ID_951583805" MODIFIED="1684425432315" TEXT="in eine mehrstufige Liste ablegen"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1684425268727" ID="ID_1433452218" MODIFIED="1684521730288" TEXT="Word-Content generieren">
|
||||
<icon BUILTIN="full-3"/>
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node CREATED="1684425436481" ID="ID_956778724" MODIFIED="1684425441508" TEXT="das Word-Dokument öffnen"/>
|
||||
<node CREATED="1684425442736" ID="ID_197631012" MODIFIED="1684427181758" TEXT="die mehrstufige Liste traversieren"/>
|
||||
<node CREATED="1684425463349" ID="ID_353388703" MODIFIED="1684425494890" TEXT="auf jedem Block-Element eine polymorphe render(wordDocument)-Funktion aufrufen"/>
|
||||
<node CREATED="1684425501667" ID="ID_343903112" MODIFIED="1684425508752" TEXT="Word-Dokument unter neuem Namen speichern"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1684368533131" ID="ID_843847965" MODIFIED="1684368539206" TEXT="Test">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
|
|
@ -453,8 +486,7 @@
|
|||
Modul <b>python-doxc</b>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
<node CREATED="1684369841851" ID="ID_82528903" MODIFIED="1684444929524" TEXT="Doku">
|
||||
<icon BUILTIN="info"/>
|
||||
<node CREATED="1684369895137" ID="ID_775368900" LINK="https://pypi.org/project/python-docx/" MODIFIED="1684369900089" TEXT="pypi.org"/>
|
||||
|
|
@ -474,8 +506,7 @@
|
|||
Beim Schreiben wird der bestehende Content verworfen und durch einen einzigen Run ersetzt, der den gegebenen Text ohne weitere Formatierungen enthält
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
@ -489,8 +520,7 @@
|
|||
Modul <b>elementtree</b>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
<node CREATED="1684444953007" ID="ID_1528197614" LINK="https://docs.python.org/3/library/xml.etree.elementtree.html" MODIFIED="1684444976183" TEXT="Doku">
|
||||
<icon BUILTIN="info"/>
|
||||
</node>
|
||||
|
|
@ -509,8 +539,7 @@
|
|||
>>> unescape('&quot;')
|
||||
'"'</code></pre>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</html></richcontent>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
|
|
@ -21,13 +21,28 @@ def convertSosci2Word():
|
|||
#
|
||||
root = ElementTree.parse(SOSCI_XML).getroot()
|
||||
|
||||
for child in root:
|
||||
print(child.tag, child.attrib)
|
||||
for section in root.findall('section'):
|
||||
title = section.find('title')
|
||||
id_prefix = getSpecificID(section)
|
||||
print("Section: Title »%s« Prefix=%s" % (title.text,id_prefix))
|
||||
|
||||
for question in section.findall('question'):
|
||||
title = question.find('title').text
|
||||
desc = question.find('description').text
|
||||
qustionType = question.find('class').text
|
||||
id_suffix = getSpecificID(question)
|
||||
id_suffix = int(id_suffix)
|
||||
questionID = "%s%02d" % (id_prefix, id_suffix)
|
||||
print("Question: ID=%s desc=%s type=%s title=%s " % (questionID, desc, qustionType, title))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Hilsmittel für SoSci-XML: extrahiert ein ID-Element, das eingeschachtelt in <attributes.specific> liegt
|
||||
def getSpecificID(element):
|
||||
attribspecific = element.find('attributes.specific')
|
||||
return next(attr.text for attr in attribspecific.findall('attr') if attr.get('id') == 'id')
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue