Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: CSV-File-Input does not import integer-data correctly

  1. #1
    Join Date
    Oct 2011
    Posts
    15

    Default CSV-File-Input does not import integer-data correctly

    Hello,

    i have written a transformation to import integer-data from a csv file. Yesterday my customer delivered a dataset with an string instead of integer: let's say 123-456-789. The csv-file-input step imports the data submitted without any error, but only the numbers up to the first "minus" were read from file, that means only "123" has been imported.

    I am supprised about this behaviour: I had expected, that PDI raises an error during casting "123-456-789" to integer, instead of cutting the string.

    Can anybody explain me this behaviour? Does a solution exist, how to prevent the csv-input-step to load "wrong" data?

    I have verified this with the latest nightly build of PDI 5, too. Same problem...

    Thank you

    Thomas

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    There is a simple reason for this behavior: Internally, type conversion is done using method parse() from class java.text.NumberFormat. This method eats as many characters from a string as can be matched by the chosen format.
    You will have to validate the field values before conversion.
    So long, and thanks for all the fish.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.