Created
February 17, 2019 16:20
-
-
Save thurask/67ccc550d115557f87c1253e2258265b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as et | |
import openpyxl | |
wb = openpyxl.Workbook() | |
tree = et.parse("Neia_MoreNamesTuning.xml") | |
root = tree.getroot() | |
workzone = root[1][2] | |
for lang in workzone: | |
langname = lang[0].text | |
nametuning = lang[1] | |
femalefirsts = [x.text for x in nametuning[0]] | |
lasts = [x.text for x in nametuning[1]] | |
malefirsts = [x.text for x in nametuning[2]] | |
wsheet = wb.create_sheet(title=langname) | |
wsheet["A1"] = langname | |
wsheet["B1"] = "FEMALE FIRST NAMES" | |
wsheet["C1"] = "MALE FIRST NAMES" | |
wsheet["D1"] = "SURNAMES" | |
worklist = [femalefirsts, malefirsts, lasts] | |
for idz, val in enumerate(worklist): | |
for idx, name in enumerate(val): | |
vname = "<T>{0}</T>".format(name) | |
wsheet.cell(column=idz+2, row=idx+2, value=vname) | |
wb.save(filename="name_book.xlsx") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment