# open csv file and convert to JSON import csv, json with open('led_map_3d.csv', 'r') as f: reader = csv.reader(f) data = list(reader) # remove first row of csv file (header) data = data[1:] output = [] # assumes 800 LEDs on your Pixelblaze, change as needed. # output format is an array of 800 points in the form of [x,y,z] for i in range (0, 800): # not all points are in the CSV # iterate over each row and see if an index matches i # if it does, add the point to output # if not, add [0,0,0] found = False for j in range (0, len(data)): index, x, y, z, _, _, _, _ = data[j] if int(index) == i: # output.append([float(x), float(y), float(z)]) output.append([-float(x), float(z), -float(y)]) found = True break if not found: output.append([0,0,0]) print(json.dumps(output))