I have a text file with some hexadecimal numbers and i am trying to convert it to decimal. I could successfully convert it, but it seems before the loop exist it reads some
with open('test.txt', 'r') as inf, open('test1.txt', 'w') as outf:
for line in inf:
line = line.strip()
if line:
try:
outf.write(str(int(line, 16)))
outf.write('\n')
except ValueError:
print("Could not parse '{0}'".format(line))