The locale module handles regional numeric conventions when European decimal strings use commas instead of periods. This matters when DuckDB ingests those values as VARCHARs, blocking numerical analysis. section 6.4
Convert locale-formatted values in DuckDB
Define convert_locale to set the de_DE locale and apply locale.atof, then register it with DuckDB. Querying Coastline and Pop. Density converts values such as 0,00, 48,0, and 124,6 into 0.0, 48.0, and 124.6. ALTER TABLE can persist the converted DOUBLE values. section 6.4
con.sql("""
SELECT "Coastline (coast/area ratio)" AS coastline,
convert_locale(coastline) as cleanCoastline,
"Pop. Density (per sq. mi.)" as popDen,
convert_locale(popDen) as cleanPopDen
FROM population
LIMIT 5
""")
┌───────────┬────────────────┬─────────┬─────────────┐
│ coastline │ cleanCoastline │ popDen │ cleanPopDen │
│ varchar │ double │ varchar │ double │
├───────────┼────────────────┼─────────┼─────────────┤
│ 0,00 │ 0.0 │ 48,0 │ 48.0 │
│ 1,26 │ 1.26 │ 124,6 │ 124.6 │
│ 0,04 │ 0.04 │ 13,8 │ 13.8 │
│ 58,29 │ 58.29 │ 290,4 │ 290.4 │
│ 0,00 │ 0.0 │ 152,1 │ 152.1 │
└───────────┴────────────────┴─────────┴─────────────┘
Inspect the original VARCHAR values beside their locale-aware DOUBLE conversions. section 6.4
