I’m parsing an XML file with some coordinates in Python to write a transformed output file. The problem is that some coordinates are -0.00 and I’m having some problems parsing them in another system. I would need them to be 0.00 instead of -0.00. How could I achieve such thing?
This is what I’m doing so far:
for node in nodes:
nodeName = node.attrib['name']
nodeParts = nodeName.split('.')
nodeName = nodeParts[0]
if nodeName == 'scene':
f.write(nodeParts[1] + '\t')
position = node.find('position')
f.write('%.2f ' % float(position.attrib['x']))
f.write('%.2f ' % float(position.attrib['y']))
f.write('%.2f\n' % float(position.attrib['z']))
If the value is equal to zero (either positive or negative), take the absolute value: