Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am currently trying to loop the result i fetched from tSystem using tJava. My workflow is:
Result from tSystem (Note : The result is much more than in example below) :
Ingestion table_202207
{'Destination TblName': u'table_202207', Execution time': 112.25, 'Ingested rows': 0}
End_table_202207
Ingestion table_202208
{'Destination TblName': u'table_2022078, Execution time': 2.20, 'Ingested rows': 764}
End_table_202208
....
In tJava:
String output=((String)globalMap.get("tSystem_3_OUTPUT"));
System.out.println("OUTPUT FROM TSYSTEM_3: "+output);
String json_output=StringUtils.substringBetween(output,"ngestion table, "End_table");
System.out.println(json_output);
//for (String i : json_output) {
// System.out.println(i);
//}
I am quite confused how should I get the value from tSystem and and loop for between string Ingestion-somedate and End_table_somedate.n
Hi
What's the output of ((String)globalMap.get("tSystem_3_OUTPUT"))? can you show an example?
what are your expect result?
Regards
Shong
Hi Shong,
Currently im trying to get the data value for multiple table using loop function using tJavaFlex in talend. The result of variable string ingestTbl in below command is:
{'Source rows': 818113, 'Destination rows': 548940}
{'Source rows': 224, 'Destination rows': 5445}
{'Source rows': 57675, 'Destination rows': 57567}
tJavaFlex command:
for (int i = 0,; i< strArray.length; i++){
String ingestTbl=StringUtils.substringBetween(output,"Ingestion Stats for Table "+strArray[i], "End_"+strArray[i]);
System.out.println(ingestTbl);
JSONObject jsonObject = new JSONObject(ingestTbl);
String sourceRowCount=(jsonObject.getString("Source rows"));
String destinationRowCount=(jsonObject.getString("Destination rows"));
globalMap.put("source_row",sourceRowCount);
globalMap.put("destination_row",destinationRowCount.trim());
}
However, in code JSONObject jsonObject = new JSONObject(ingestTbl);, i received error:
What should I do to loop the result from ingestTbl to jsonObject so that I can bring the result for further process?
It is a compilation error, output cannot be resolved to a variable in this line:
String ingestTbl=StringUtils.substringBetween(output,"Ingestion Stats for Table "+strArray[i], "End_"+strArray[i]);
Why don't you use tWriteJsonField if you want to generate a Json string?
Hi,
I dont think that issue come from that variable. as if I run that line itself, it outputs.
table 1 {'Source rows': 818113, 'Destination rows': 548940} - for all table with respective result.
Next step is to convert the string result to jsonObj and use globalMap to fetch the result.
From ingestTbl result, is there any way to use substringBetween?