ちょっとした助けが必要です。次のxmlが次のようにフォーマットされているとしましょう:
<Solution version="1.0">
<DrillHoles total_holes="238">
<description>
<hole hole_id="1">
<hole collar="5720.44, 3070.94, 2642.19" />
<hole toe="5797.82, 3061.01, 2576.29" />
<hole cost="102.12" />
</hole>
........
編集:これは、穴の襟を作成するために使用したコードです..など.
for row in reader:
if i > 0:
x1,y1,z1,x2,y2,z2,cost = row
if current_group is None or i != current_group.text:
current_group = SubElement(description, 'hole',{'hole_id':"%s"%i})
collar = SubElement (current_group, 'hole',{'collar':', '.join((x1,y1,z1))}),
toe = SubElement (current_group, 'hole',{'toe':', '.join((x2,y2,z2))})
cost = SubElement(current_group, 'hole',{'cost':cost})
i+=1
など、ホール カラー、ホール トウ、ホール コスト データを取得する方法を教えてください。これまでのところ私のコードは次のとおりです。私は本当に近いと思います。
with open(outfile, 'w') as file_:
writer = csv.writer(file_, delimiter="\t")
for a in zip(root.findall("drillholes/hole/hole collar"),
root.findall("drillholes/hole/hole toe"),
root.findall("drillholes/hole/hole cost")):
writer.writerow([x.text for x in a])
私のプログラムはcsvファイルを生成しますが、csvファイルは空です。そのため、検索と検索のエラーのためにこのコードがデータを取得できなかったと思います。誰でも助けることができますか?