• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » convert decimal (comma to dot) postgres

#1 2007-07-04 18:29:48

didierkisscool
Member
Registered: 2007-04-10
Posts: 15

convert decimal (comma to dot) postgres

Tags: [java, routine]

Hi guys

It's me ... again !!! big_smile

Here is an example of my file
_________________________

15;2013;25/02/1998;3;999;1;1003,49
15;2105;25/02/1998;3;999;1;1003,49
...
Well I want to convert decimal text column to floating point Postgres Column.

when i try to do that i've got an cute error message sad
_________________________________________________________________
tarting job job_2 at 18:17 04/07/2007.
[statistics] connecting to socket on port 3334
[statistics] connected
Exception in component tFileInputDelimited_1
java.lang.NumberFormatException: For input string: "1003,49"
    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
    at java.lang.Float.parseFloat(Unknown Source)
    at routines.system.ParserUtils.parseTo_float(ParserUtils.java:50)
    at projet_1.job_2.job_2.tFileInputDelimited_1Process(job_2.java:296)
    at projet_1.job_2.job_2.main(job_2.java:536)
[statistics] disconnected

Job job_2 ended at 18:18 04/07/2007. [exit code=0]

My question ...
Is there an numeric pattern or an other trick to convert my column ?
like that 1003,49 to 1003.49

THX
Regards ...

Didier
_____________________
Under Windows XP
TOS:v2.1.0.M1_r3483
Oracle 10g
Postgres 8.2.3
jre 1.6

_________________________________________________________________


Uploaded Images

Last edited by didierkisscool (2007-07-04 18:37:34)

Offline

#2 2007-07-05 01:05:19

mhirt
Talend team
Registered: 2006-09-19
Posts: 1633

Re: convert decimal (comma to dot) postgres

Hello

Problem is that , is not the decimal separator in Java.
You have to read your fields as a String.
Then you can parse it and convert it as a Float in a tMap : new Float(row.fieldName.replace(',', '.'))

Regards,

Offline

#3 2007-07-05 10:40:11

didierkisscool
Member
Registered: 2007-04-10
Posts: 15

Re: convert decimal (comma to dot) postgres

hi wink

oki I try and  i keep you informed
i saw the hour of your answer ... lol go to sleep !!! big_smile

thx a lot
Regards

Offline

#4 2007-07-06 16:28:26

didierkisscool
Member
Registered: 2007-04-10
Posts: 15

Re: convert decimal (comma to dot) postgres

Hi ...
it work !

Thaaaaaaaanks big_smile

Have fun wink

Regards !

Offline

#5 2007-12-27 18:35:26

matthieu
Guest

Re: convert decimal (comma to dot) postgres

Hello Didier,

I'm facing the same trouble as you did : wanna change decimal separator ',' by '.' from string to float.

I've tried to use a tMap Component with this piece of code :new
Float(row.fieldName.replace(',', '.'))

It fails... Where should I write this expression ?

I'm new to Talend so it would be very kind to help me.

#6 2007-12-28 08:51:41

shong
Talend team
Registered: 2007-08-29
Posts: 10289
Website

Re: convert decimal (comma to dot) postgres

Hi  matthieu

See [Forum, topic 1846] Pb remontée fichier Excel vers Table As400.

Best regards

        shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#7 2009-08-07 09:02:25

we
Guest

Re: convert decimal (comma to dot) postgres

mhirt wrote:

Hello

Problem is that , is not the decimal separator in Java.
You have to read your fields as a String.
Then you can parse it and convert it as a Float in a tMap : new Float(row.fieldName.replace(',', '.'))

Regards,

This my problem Thank you very muchhhh... smile))

#8 2009-08-07 16:17:32

emaxt6
Member
Registered: 2008-08-04
Posts: 325

Re: convert decimal (comma to dot) postgres

in tfileinputdelimited you can set in advanced option custom decimal separaton, so custom coding not needed

bye

Offline

#9 2009-08-10 11:53:22

yuan
Guest

Re: convert decimal (comma to dot) postgres

didierkisscool wrote:

Hi guys

It's me ... again !!! :D

Here is an example of my file
_________________________

15;2013;25/02/1998;3;999;1;1003,49
15;2105;25/02/1998;3;999;1;1003,49
...
Well I want to convert decimal text column to floating point Postgres Column.

when i try to do that i've got an cute error message :(
_________________________________________________________________
tarting job job_2 at 18:17 04/07/2007.
[statistics] connecting to socket on port 3334
[statistics] connected
Exception in component tFileInputDelimited_1
java.lang.NumberFormatException: For input string: "1003,49"
    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
    at java.lang.Float.parseFloat(Unknown Source)
    at routines.system.ParserUtils.parseTo_float(ParserUtils.java:50)
    at projet_1.job_2.job_2.tFileInputDelimited_1Process(job_2.java:296)
    at projet_1.job_2.job_2.main(job_2.java:536)
[statistics] disconnected

Job job_2 ended at 18:18 04/07/2007. [exit code=0]

My question ...
Is there an numeric pattern or an other trick to convert my column ?
like that 1003,49 to 1003.49

THX
Regards ...

Didier
_____________________
Under Windows XP
TOS:v2.1.0.M1_r3483
Oracle 10g
Postgres 8.2.3
jre 1.6

_________________________________________________________________

Problem is that , is not the decimal separator in Java.
You have to read your fields as a String.
-----------------------------------------------------------------------
tuyen dung | viec lam | tim viec

#10 2009-08-10 11:53:52

yuan
Guest

Re: convert decimal (comma to dot) postgres

didierkisscool wrote:

Hi guys

It's me ... again !!! :D

Here is an example of my file
_________________________

15;2013;25/02/1998;3;999;1;1003,49
15;2105;25/02/1998;3;999;1;1003,49
...
Well I want to convert decimal text column to floating point Postgres Column.

when i try to do that i've got an cute error message :(
_________________________________________________________________
tarting job job_2 at 18:17 04/07/2007.
[statistics] connecting to socket on port 3334
[statistics] connected
Exception in component tFileInputDelimited_1
java.lang.NumberFormatException: For input string: "1003,49"
    at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
    at java.lang.Float.parseFloat(Unknown Source)
    at routines.system.ParserUtils.parseTo_float(ParserUtils.java:50)
    at projet_1.job_2.job_2.tFileInputDelimited_1Process(job_2.java:296)
    at projet_1.job_2.job_2.main(job_2.java:536)
[statistics] disconnected

Job job_2 ended at 18:18 04/07/2007. [exit code=0]

My question ...
Is there an numeric pattern or an other trick to convert my column ?
like that 1003,49 to 1003.49

THX
Regards ...

Didier
_____________________
Under Windows XP
TOS:v2.1.0.M1_r3483
Oracle 10g
Postgres 8.2.3
jre 1.6

_________________________________________________________________

Problem is that , is not the decimal separator in Java.
You have to read your fields as a String.
-----------------------------------------------------------------------
tuyen dung | viec lam | tim viec

#11 2012-02-15 09:46:19

littledirk
Member
Registered: 2011-07-28
Posts: 17

Re: convert decimal (comma to dot) postgres

Hi,

I have a similar problem.

Input string: "139,95 €"

Expected output: "13995" Typ int.

I've solved this problem by using the treplce component (see image), but i think it is possible to do all the stuff in tmap component? am i right?


Uploaded Images

Last edited by littledirk (2012-02-15 09:47:55)

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » convert decimal (comma to dot) postgres

Board footer

Powered by FluxBB