Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there,
I receive JSON files having thousands of lines and I want to divide it into 'n' blocks having the same key.
For instance let's say I have the following input data:
[{key:A, key2=abc}; {key:A, key2=abe}, {key:B, key2=zyw}, {key:B, key2=123}, {key:C, key2=fgh}]
I want to split the above into 3 blocks: A, B, C
I've tried using tFlowToIterate but I can't find the Talend's way to split on a condition and then process the end of the job for each split...
Could someone indicate a way? Thx!
Hi,
Since, I think, your key is random, you can't use XPath to extract blocks.
Given that, you should split your JSON into 5 lines like this :
{key:A, key2=abc}
using a tNormalize components on the JSON String.
Then you extract, and "tag" your line with the key and use a tAggregateRow to build a List.
Using .toString() method on the list will output all data, separated by a comma. Feel free to adapt the mechanism.
Sincerely