You are not logged in.
Announcement
Unanswered posts
|
Pages: 1
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
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:
$ 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:
# 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:
plegall|2.468 olcell|4.69 xavier|6.912
Offline
Pages: 1