• Index
  •  » Talend Open Studio for Data Integration » Installation
  •  » decimal caracter with fileinputdelimited

#1 2006-10-10 09:43:57

xavier
New member
Company: Nice - France
Registered: 2006-10-09
Posts: 6

decimal caracter with fileinputdelimited

I try to load a file delimited by tab with coma as decimal caracter but it doesnt work. TOS expected a point as decimal caracter. How can i do to significate that the decimal caracter is a coma and not a point ?

Offline

#2 2006-10-10 12:50:53

plegall
Member
Registered: 2006-09-19
Posts: 1586
Website

Re: decimal caracter with fileinputdelimited

I've been searching Perl discussion newgroups and there is a solution based on POSIX module. See Calculations with ',' as decimal delimiter. But the solution I advise you is the tr/,/./;

Here is how to put this solution in practice: create a job with a tFileInputDelimited, a tPerlRow and a tFileOutputDelimited, all linked with row type link (see attached screenshot).

In my input file, I have:

Code:

$ cat comma_decimal_numbers.txt
plegall 1,234
olcell  2,345
xavier  3,456

The schema associated to my tFileIOnputDelimited is made of two columns : "username" and "random_number". I synchronize the columns of tLogRow (thus copying the schema in the tPerlRow and tLogRow).

The Perl code in the tPerlRow is:

Code:

# replacing commas with dots
$row[random_number] =~ tr{,}{.};

# just to show that the field is considered as a number now
$row[random_number] *= 2;

The output of the tLogRow is:

Code:

plegall|2.468
olcell|4.69
xavier|6.912

Uploaded Images

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Installation
  •  » decimal caracter with fileinputdelimited

Board footer

Powered by FluxBB