from your example, it seems that it is not possible to read the string “00001” directly into the decimal 0.0001. As you rightly indicated, you would have to take advantage of the Reformat component to achieve the desired format. I would suggest taking this path:
- Read the input fields (field3 and field4) as strings (“00001”).
- Add the Reformat component into your graph and assign the output metadata as per your example (<Field format="0.0000" length="5" name="fieldX" scale="4" size="5" type="decimal"/>).
- Use the following transformation in the reformat transform function:
Code: Select all
$out.0.FieldX = str2decimal(charAt($in.0.FieldX, 0) + "." + substring($in.0.FieldX, 1));
Note: the charAt() function grabs the first character (index position 0 in the input string) and concatenates it with the dot character and the substring of the input string (from the index position 1 onwards).
If this does not meet your needs (for example due to the higher complexity of the actual input file), feel free to get back to us with more details.