Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readdlm doesn't know about comma decimal mark #11

Open
Ilya87 opened this issue Aug 25, 2014 · 5 comments
Open

readdlm doesn't know about comma decimal mark #11

Ilya87 opened this issue Aug 25, 2014 · 5 comments
Labels

Comments

@Ilya87
Copy link

Ilya87 commented Aug 25, 2014

In some countries comma is a decimal mark, but readdlm has no option to recognize it. So when I do
x=readdlm("/home/ilya/Works/Julia/12.csv", ';')
for file that contains numbers like 18,8205, then
mean(x)
ERROR: + has no method matching +(::SubString{ASCIIString}, ::SubString{ASCIIString})
Trying do x=readdlm("/home/ilya/Works/Julia/12.csv", ';',Float32)
ERROR: file entry "18,8205" cannot be converted to Float32
I should open 12.csv file in editor and replace all commas with point and only this solves the problem.

@tanmaykm
Copy link

readdlm uses float64_isvalid which finally uses the C locale.

related: JuliaLang/julia#6593

@elextr
Copy link

elextr commented Aug 25, 2014

If locale capability is added to things like readdlm it must be explicit, just because a computer is running in a ',' or '.' locale does not mean the data is in that format.

And the default should not be to use the computer's locale, it is really bad Karma if a program which works in one locale mysteriously fails in another when processing the same data.

@nalimilan
Copy link
Member

@elextr It's not what @tanmaykm said. On the contrary, readdlm always uses the C locale, which prevents the behavior from changing depending on the current locale. What is needed is a way to specify a custom decimal mark, as you asked.

@elextr
Copy link

elextr commented Aug 25, 2014

@nalimilan indeed, I said "if locale capability is added", rather than referring to current behaviour :)

As @Ilya87 pointed out there is data with differing locale specific formats, and maybe its useful to add the capability to accept such data (rather than having to edit the file to replace the commas with dots).

I was just pointing out that it needs to be explicit depending on the locale format of the data not the computer locale since its a common mistake to conflate the two.

@tknopp
Copy link

tknopp commented Aug 25, 2014

This needs a fix of JuliaLang/julia#6593 which I could tackle. The question is more how the interface of these locale specific functions should look like. Lets keep that dicussion in JuliaLang/julia#6593.

@kshyatt kshyatt added the I/O label Sep 15, 2016
@ViralBShah ViralBShah transferred this issue from JuliaLang/julia Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants