I want to parse a CSV file which some columns have...
# datascience
e
I want to parse a CSV file which some columns have to be
BigDecimal
, what is the proper way of parsing the numeric values? I added breakpoint and found that DataFrame was trying to parse the values in
Double
a
I do not remember if Commons-csv has this option, but proper way is to parse them as strings.
j
Hi! DataFrame indeed parses numeric columns with decimals to Double by default. However, you can pass a
colTypes: Map<String, ColType>
argument to DataFrame.readCsv() containing
mapOf("yourColName" to ColType.BigDecimal)
to nudge it in the right direction.
👍 3