akarshan2701 / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

comma radix #97

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
This is a feature request.

Would like to be able to specify the decimal point character in csvread. 
In North America its normally a dot (.) but in certain countries its
commonly a comma (,).  Its already possible to do this:

https://groups.google.com/group/h2-database/msg/156f138a9bd03027

but for something that is potentially very common (at least if your data is
normally from such countries) what is really needed is to make it as easy
as specifying a separator such as by providing an argument to csvread for this.

I believe that some databases handle it through interaction with the
localization facilities of the OS; however, that only helps if ALL your
data is of that form.  In the R language its handled with a dec= argument
on the read command which is more flexible.

If its already possible then all that is needed is to document how to do it.

Original issue reported on code.google.com by ggrothendieck@gmail.com on 11 Jul 2009 at 5:39

GoogleCodeExporter commented 8 years ago
Hi,

CSVREAD returns VARCHAR for all columns, so converting comma to a dot within 
CSVREAD
would be the wrong place. If you use CSVREAD as a table to insert into or create
another table, the data is converted using the default conversion, for example 
CAST(x
AS DECIMAL). This conversion is not local specific, and I don't plan to add 
such a
feature as other databases also don't support it (as far as I know). I also 
don't
plan to add a feature request, sorry.

You could use REPLACE: http://www.h2database.com/html/functions.html#replace - 
or you
could create a special java function to do that (see CREATE ALIAS).

I would try to avoid using a comma however.

Original comment by thomas.t...@gmail.com on 13 Jul 2009 at 7:04