Hello everyone. I have a question about the `dataF...
# datascience
s
Hello everyone. I have a question about the
dataFrame
project. I would like to use custom enums, as property read from CSV. Is there a way to do it? Thanks 👍
n
Hi! If you already have an enum declaration
Copy code
enum class Direction {
    NORTH,
    SOUTH,
    WEST,
    EAST,
}
You can do this
Copy code
dataFrameOf("direction")("NORTH", "WEST")
    .convert("direction").to<Direction>()
Is this what you want, or something more generic / automatic?
s
hey @Natalia Mishina my case was:
Copy code
id,name,direction,flag
1,Austin,SOUTH,0x11
2,Canada,NORTH,0x12
and I managed to use like this
Copy code
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.
👍 1