CSV.jl icon indicating copy to clipboard operation
CSV.jl copied to clipboard

Ability to specify a thousands separator character

Open jaakkor2 opened this issue 4 years ago • 3 comments

This feature was listed in https://github.com/JuliaData/CSV.jl/issues/3 , but not implemented.

https://github.com/JuliaData/CSV.jl/issues/207 has a complicated workaround (but keyword transforms does not exists anymore?), and says "there isn't a "thousands" separator option, but we could potentially add on".

Practical example, data is two first rows from table 2 on page 10 in https://www.istat.it/it/files//2020/05/Rapporto_Istat_ISS.pdf

a=CSV.File(IOBuffer("""
       Alessandria 95,7 98,2 -12,8 91,0 1.199 693 222 18,5
       Ancona 76,6 84,3 -10,7 49,4 704 528 86 12,2
       """), delim=" ", header = false, decimal = ',')

Row 1, column 6 would ideally be Int 1199. Here comma is a decimal separator and period is a thousands separator.

jaakkor2 avatar May 04 '20 18:05 jaakkor2

Bumping this. We are working on a package to make it easier to copy and paste from Excel and using CSV as the backend.

I have a feeling there are a lot of excel workbooks where the data is stored as a number, shown with commas, and then when you copy and paste the commas are retained. This is how google sheets work at least.

pdeffebach avatar Apr 28 '21 15:04 pdeffebach

This feature would be useful for me, too.

lungben avatar Jun 28 '21 09:06 lungben

This would be really useful for me too

mkborregaard avatar Jan 04 '22 17:01 mkborregaard

Bump, I'm also running into this issue.

My workaround is to parse normally and then post-process with parse(Float64, replace(string(x), ',' => ""))

LilithHafner avatar Dec 19 '22 14:12 LilithHafner

Hmmm, @Drvi, where did we land on this? We added support in Parsers.jl, but did we plumb the functionality through CSV.jl? It should be pretty easy to support in CSV.jl now that it's supported in Parsers.jl. (just need to plumb through the groupmark keyword arg to the Parsers.Options constructor)

quinnj avatar Dec 19 '22 14:12 quinnj

@quinnj Yeah, things should be ready in Parsers.jl. Only single-byte groupmarks are supported.

Drvi avatar Dec 19 '22 15:12 Drvi

bump

bkamins avatar Feb 05 '23 11:02 bkamins

Bump

AndreasKuhn-ak avatar Jun 02 '23 13:06 AndreasKuhn-ak

Huzzah!

LilithHafner avatar Jun 05 '23 15:06 LilithHafner