holgerbrandl / krangl

krangl is a {K}otlin DSL for data w{rangl}ing
MIT License
560 stars 50 forks source link

Column Type Guess #74

Closed fmgonsalves closed 4 years ago

fmgonsalves commented 5 years ago

Hello,

When reading a CSV file, I was wondering if there was any way I could specify not to "peek" into the first 100 samples of a column, but rather, intuit the column type from all the data in the column. Is there such functionality possible when reading a CSV file?

Fred

holgerbrandl commented 5 years ago

Hi there,

the corresponding parser method has an argument to specify the peek size, which could be set to infinity to read all data in the table. See https://github.com/holgerbrandl/krangl/blob/8774405ba26954f0d6b7c024ae623966c3e4a4e4/src/main/kotlin/krangl/TableIO.kt#L263

However, it is not yet exposed to readCsv . It's clearly planned, but feel welcome to submit a PR to change this right away.

Alternatively, you could already specify the column types manually and avoid any column type inference.