I have a dataset that I’m returning from an SQL query, however I need to post-process it to convert a few of the fields to java.awt.Color object types. They’re incoming as strings e.g. “java.awt.Color[r=25,g=23,b=123]”
Is there a simple way to do this?
What I’m doing at the moment is super clunky:
- get the headers from the dataset
- get the first row as a list
- convert all of the colour columns in the list to a colour object using e.g.: system.gui.color(“java.awt.color([…])”). Now this list contains colour objects rather than colours as strings.
- create a dataset from these lists
- join the SQL dataset to this new dataset, thereby forcing the SQL dataset to use the new java.awt.Color type
- delete the original column…
I tried using system.dataset.clearDataSet()
in between steps 3 and 4, but this seemed to not retain the column type.
EDIT:
This logic however doesn’t work sometimes, especially if the first row has some NoneType values in it, I think… I’m pulling my hair out trying to get this working