I’m now trying to generate a file with test data. I have set up a graph with a DataGenerator component. I want the first field of the output file to be a numerical sequence of 10 digits. It is working but not really as numerical sequence, I mean, it is left justified and not right.
For example, it is generating something like this:
This is not what I would expect from a numerical sequence but something like the following (using underscore instead of space because the forum does not respect initial spaces):
Hi dalonso,
I would suggest to use Reformat component to sort it out. Its transformation could look as follows:
$0.field1 := right(’ ’ + $0.field1, 10);
$0.field2 := $0.field2;
Where the field1 is an integer on input and string on output
Field2 is string on both sides.
Number of spaces I used on first row of transformation depends on your needs(lenght of your sequence).
thanks, it’s a good solution and I will be using it.
Though performance wise I hoped to be able to save one component in the graph.
I’m going to work with big, big files, so using the Reformat component means traversing all the file, for reformatting all the records, when it could have been done in the origin. From my point of view, it’s a pity if the sequence does not honour the format of the receiving field (all integers should be rigth justified in my oppinion).
If you want to pad the field by a serie of 0-s from the left, you only need to set the Format attribute for this field to 0000000000.
This way, the numbers will be completed to 10 digits by 0-s from the left.
Click the desired field in the left pane of Metadata editor and set the Format attribute in the Field pane on the right side of this editor to the following string: 0000000000.
You will not need any Reformat and you will obtain field values in the form as you want.