Houdini Python. i have a text file where every line contains point data in this format : x1, y1, size1, hex_value1 , x2, y2, size2, hex_value2,…i want to read in houdini python this file, get all the unique hex values and replace the original with their corresponding indices, so x1, y1, size1, hex_value1 , x2, y2, size2, hex_value2,.. will become this x1, y1, size1, index1 , x2, y2, size2, index2,..
Use my code as base :
import os
node = hou.pwd()
geo = node.geometry()
#get parms
filepath = node.parm(‘filepath’).evalAsString()
output = node.parm(‘output’).evalAsString()
framestart = node.parm(‘framerangex’).evalAsInt()
isExist = os.path.exists(filepath)
outExist = os.path.exists(output)
if isExist:
# print(“INPUT file: ” + filepath + ” EXISTS!”)
if outExist:
print(“OUTPUT file: ” + output + ” EXISTS!”)
else:
# Read txt file line by line
file1 = open(filepath, ‘r’)
Lines = file1.readlines()
i have also attached the input file