Created
October 30, 2019 02:02
-
-
Save usaturn/f2708576ea63da17f6c4d194fac08c16 to your computer and use it in GitHub Desktop.
csv に従って XML を吐く
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
from jinja2 import Template, Environment, FileSystemLoader | |
import csv | |
env = Environment(loader=FileSystemLoader('.'), encording='utf-8', autoescape=True) | |
template = env.get_template('temp02.xml.j2') | |
with open("kamiwaza.csv", newline="") as csvfile: | |
kamiwazareader = csv.reader(csvfile, delimiter=",", quotechar="|") | |
for row in kamiwazareader: | |
number = row[0] | |
style = row[1] | |
kamiwaza = row[2] | |
pronunciation_of_kamiwaza = row[3] | |
explanation = row[4] | |
conditions_for_experience_points = row[5] | |
data = { | |
"number": number, | |
"style": style, | |
"kamiwaza": kamiwaza, | |
"pronunciation_of_kamiwaza": pronunciation_of_kamiwaza, | |
"explanation": explanation, | |
"conditions_for_experience_points": conditions_for_experience_points, | |
} | |
rendered = template.render(data) | |
print(str(rendered)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment