Following Creating polygon from 2 txt files (Parent ID + Coordinates) from a few weeks ago, the script works very well. Now I need to reverse the process in order to update the Z value in the original text file describing a mesh.
From a first table of Points coordinates (Nnodes, resulting from Export Feature Attribute to ASCII):
#Nnodes
# X Y ID Z
4403607.48 5788195.96 56362 87.6
4403550.41 5788192.5 56951 93.4
I want to update the Z value from Nnodes to Mesh_orig,using the Point IDs as common keys
# Mesh_orig
#Geom ID X Y Z
ND 56362 4403607.48 5788195.96 86.1
ND 56951 4403550.41 5788192.5 91.3
It prints only the last row of Nnodes instead of the whole updated mesh_dict.
with open (r'text2.txt','r+') as Mesh:
for row in Mesh:
if row.startswith('ND'):
Inline= row.split()
mesh_dict={Inline[1]:Inline[4]}
KeyM = mesh_dict.keys()
ValueM = mesh_dict.values()
with open (r'Text1.txt','r') as Npoint:
for KeyM in mesh_dict:
for lines in Npoint:
Outlines= lines.split()
point_dict={Outlines[-2]:Outlines[-1]}
KeyP = point_dict.keys()
ValueP = point_dict.values()
if KeyM in point_dict:
point_dict.update(mesh_dict)
print str(KeyM)+", "+str(ValueP)
Where is it going wrong?