Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I need to count specifics occurences on XML ("true" or "false") and get the results in a table
I try using a tXMLMap but so far without success.
Any idea where I can lookinf for?
My XML:
<?xml version="1.0" encoding="UTF-8"?>
<customers>
<customer id="1">
<customerStatus vip="false" gold="false"/>
</customer>
<customer id="2">
<customerStatus vip="true" gold="false"/>
</customer>
<customer id="3">
<customerStatus vip="true" gold="true"/>
</customer>
</customers>
Wishes result:
| vip | gold|
| 2 | 1 |
Hi
Using a tFileInputXML to read this XML file and extract vip and gold value, filter the 'true' value on tFilterRow and count it with tAggregateRow.
Please try and let me know if you have any questions.
Regards
Shong
Thanks I have a begin on something now 🙂
It works for the values "gold" and "vip" separately but how to count them together?
I tried to make the filter in a tXMLMap to have on one flow the "gold" values and on the other the "vip"values both followed by a tAggregateRow but then it doesn't seem possible to use a tUnite to group them.
Same with tReplicate ==> tFilterRow ==> tAggregateRow : impossible to use tUnite after ...
How I can proceed?
It is impossible to use tUnite after, this is not allowed to do in a cycle flow. As a workaround, you can store the counting result to global variable or context vairalbe on a tJavaRow, and then generate a new row for these two counting result on a tFixedFlowInput in next subjob.
eg:
....AggreGateRow--main--tJavaRow1
|onsubjobok
tFixeFlowInput--main--tLogRow
tJavaRow1:
context.sum_of_glod=input_row.gold
on tFixedFlowInput, define two columns:vip and glod, set their values with corresponding context variable.
Regards
Song
Thanks fot the tips
What I did:
tFileInputXml -> tXMLMap
|onsubjobok
tFileInputDelimited_1 --main--
tFileInputDelimited_2 --Lookup--
Thanks for your feedback! Personally, I'd like to store small temporary datasets in memory rather than writing to the filesystem.
my sample is small but my use case is huge 😉
This makes sense! In addition, remove the temporary file in the end of job if it isn't used any more; use context variable as file path if the job will be migrated to other environment, so that you can assign a new file path through job executable file if needed.