Thank you very much.
But I needed to add the charge in the correct place, as a third-party application will use such information.
I also asked for help at
Bioinformatics Stack Exchange forum, and got the answer below for a working Python code:
######
pdb = 'input_connect.pdb'
charges = 'sistema20.charges'
charges_list = []
with open(charges , 'r') as handle :
for i in handle.readlines() :
charges_list.append(i.strip())
print(charges_list)
with open(pdb , 'r') as handle :
pdb_file = handle.readlines()
print(pdb_file)
idx = 0
with open('result_python.pdb' , 'w') as handle :
for i in pdb_file :
i = i.strip()
if i[0:6] == 'HETATM' :
i = i +' '+ charges_list[idx] +'\n'
idx += 1
handle.writelines(i)
else :
i = i + '\n'
handle.writelines(i)
######