Sinan Gunes
11/19/2024, 2:25 PMdataFrame
project. I would like to use custom enums, as property read from CSV. Is there a way to do it?
Thanks 👍Nikita Klimenko [JB]
11/19/2024, 3:38 PMenum class Direction {
NORTH,
SOUTH,
WEST,
EAST,
}
You can do this
dataFrameOf("direction")("NORTH", "WEST")
.convert("direction").to<Direction>()
Is this what you want, or something more generic / automatic?Sinan Gunes
11/19/2024, 5:45 PMid,name,direction,flag
1,Austin,SOUTH,0x11
2,Canada,NORTH,0x12
and I managed to use like this
val cities = DataFrame.readCSV(file).convertTo<Map> {
parser { it.hexToInt(format) }
}
thanks for the response.
----
A small feedback:
the whole convertTo
is magic without deterministic order or field selector. And the documentation there could be improved.