BrianHicks / elm-csv

Decode CSV in the most boring way possible.

Home Page:https://package.elm-lang.org/packages/BrianHicks/elm-csv/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should it support files with empty last line?

jpagex opened this issue · comments

I do not know if this would be desirable, but at the moment, if the file has the last line empty, there is an error like:

There was a problem on row -1: I looked for a column named `Population`, but couldn't find one.

SSCCE (Short Self-Contained Correct Example):

decodeCustom
    { fieldSeparator = '\t' }
    FieldNamesFromFirstRow
    (map2 Tuple.pair
        (field "Country" string)
        (field "Population" int)
    )
    "Country\tPopulation\nArgentina\t44361150\nBrazil\t212652000\n"
    |> Result.mapError errorToString

If I remove the last \n it works fine.

Is this feature desirable or should we make sure the files do not have an empty line at the end?

ah, no, that's a bug. Thanks for bringing it up!

also, wow, sorry about that error message 🙈