Skip to content

Parsing numerical values which use comma rather than a point #175

@idontgetoutmuch

Description

@idontgetoutmuch

Some countries use 3,1459 rather than 3.1459. I have for example

"LATITUDE","LONGITUDE"
"-21,5245377777","-39,6610013888"
"-9,5933511111","-35,8891097222"

But if I run

{-# LANGUAGE DataKinds, FlexibleContexts, QuasiQuotes, TemplateHaskell, TypeApplications #-}

{-# OPTIONS_GHC -Wall -Wno-type-defaults #-}

import           Frames
import qualified Pipes.Prelude as P

tableTypes "Row" "mwe.csv"

tbl2a :: IO [ColFun Maybe Row]
tbl2a = runSafeT . P.toListM $ readTableMaybe "mwe.csv"

main :: IO ()
main = tbl2a >>= mapM_ (putStrLn . show)

Then Frames seems to parse these values as doubles:

main
{Just LATITUDE :-> -2.15245377777e11, Just LONGITUDE :-> -3.96610013888e11}
{Just LATITUDE :-> -9.5933511111e10, Just LONGITUDE :-> -3.58891097222e11}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions