One Star

Converting multiple rows into one

Hi, I have a fixed flow input producing three rows, each with the field 'name' and 'role.
I want to output all of the rows in a single row and single field in the fileoutputdelimited.
The reason for this is that I need to convert the incoming rows to a json like format.
(I already know about the component to write json fields - it's not what I need)
I've tried using jJavaFlex with the main block building a string and the end block propagating the row, but it seems to just pass a row out for each incoming row anyway.
6 REPLIES
One Star

Re: Converting multiple rows into one

Hi,
Try this: tFixedFlowInput------row1---(main)------tJavaRow
suppose you put your three colmun in a context variable
In your tJavaRow : context.mergethreerow=row1.column1+row1.column2+row1.column3;
One Star

Re: Converting multiple rows into one

Thanks, but I actually need values from each row to combine into a single field in a single row e.g.
So input rows are (just an example):
Row1
--------
name: Mike
role: Author
Row2
------
name:Jo
role: Illustrator

tFixedFlowInput .... row1(main) (2 rows)---> tJavaFlex ------ row2(main) (1 row) -----> tOutputFileDelimeted

Output would be 1 row containing:
Attributex: { "contributors" : }
If anyone can achieve this exact output using another component that already exists please let me know.
In my real job, I don't want to append the rows to a variable and then use a separate subjob, because this flow is contributing to an XML file that's being built, and I don't think I can add into the XML structure after the file is written? he above is just an example to illustrate the principle of many rows to one.
One Star

Re: Converting multiple rows into one

I read another thread on this forum and am following the advice there, the job isn't working yet, but I think it will.
One Star

Re: Converting multiple rows into one

Please post this topic URL so someone reading this will get to the solution quicker Smiley Happy
One Star

Re: Converting multiple rows into one

Re: Converting multiple rows into one

HI ,
I have the Table with columns "REPORT_INFO_ID","REPORT_ID","SECTION_CODE","SOURCE_NAME","JSON_OUTPUT","METRIC_NAME","SEQUENCE"
"JSON_OUTPUT" column has JSON format in multiple levels  (Means each record in that column has a json format).
json files are there as per source systems...now how i can process the data.
sample data as in below:
 
REPORT_INFO_IDREPORT_IDSECTION_CODESOURCE_NAMEJSON_OUTPUTMETRIC_NAMESEQUENCE
162APIGEE_AVG_RESP_TIMEAPIGEE{  "Response" : {    "TimeUnit" : ,    "metaData" : {      "errors" : ,      "notices" :     },    "stats" : {      "data" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      }, {        "identifier" : {          "names" : ,          "values" :         },        "metric" :         }, {          "env" : "prod",          "name" : "total_response_time",          "values" :         }, {          "env" : "prod",          "name" : "tps",          "values" :         } ]      } ]    }  }}AVGNULL
172SPLUNK_AVG_RESP_TIMESPLUNK{"preview":false,"init_offset":0,"messages":[],"fields":,"results":, "highlighted":{}}AVGNULL
182SPLUNK_RESP_TIME-PKYSPLUNK{"preview":false,"init_offset":0,"messages":[],"fields":,"results":","Total":"22","0.5%":"54.5","1%":"18.2","2%":"18.2","3%":"9.1","5%":"0.0","7%":"0.0","10%":"0.0","10-28%":"0.0","Timeout%":"0.0"},{"RequestFormat":"Catalog Calls ","Total":"248923","0.5%":"97.9","1%":"1.9","2%":"0.2","3%":"0.0","5%":"0.0","7%":"0.0","10%":"0.0","10-28%":"0.0","Timeout%":"0.0"},{"RequestFormat":"Inventory Service Calls","Total":"18402","0.5%":"89.3","1%":"8.6","2%":"1.8","3%":"0.3","5%":"0.0","7%":"0.0","10%":"0.0","10-28%":"0.0","Timeout%":"0.0"},{"RequestFormat":"Order API - Estimate Payment","Total":"13","0.5%":"92.3","1%":"0.0","2%":"7.7","3%":"0.0","5%":"0.0","7%":"0.0","10%":"0.0","10-28%":"0.0","Timeout%":"0.0"},{"RequestFormat":"Price Service Calls","Total":"25818","0.5%":"100.0","1%":"0.0","2%":"0.0","3%":"0.0","5%":"0.0","7%":"0.0","10%":"0.0","10-28%":"0.0","Timeout%":"0.0"},{"RequestFormat":"Profile API Calls","Total":"69539","0.5%":"99.7","1%":"0.2","2%":"0.0","3%":"0.0","5%":"0.0","7%":"0.0","10%":"0.0","10-28%":"0.0","Timeout%":"0.0"},{"RequestFormat":"v1 ordercalc","Total":"124365","0.5%":"85.7","1%":"11.5","2%":"2.4","3%":"0.4","5%":"0.1","7%":"0.0","10%":"0.0","10-28%":"0.0","Timeout%":"0.0"},{"RequestFormat":"v1 place order","Total":"832","0.5%":"0.4","1%":"2.6","2%":"9.4","3%":"51.8","5%":"31.0","7%":"3.8","10%":"0.8","10-28%":"0.1","Timeout%":"0.0"},{"RequestFormat":"v2 ordercalc","Total":"99486","0.5%":"45.0","1%":"40.5","2%":"12.0","3%":"1.7","5%":"0.6","7%":"0.1","10%":"0.1","10-28%":"0.0","Timeout%":"0.0"},{"RequestFormat":"v2 place order","Total":"2709","0.5%":"1.3","1%":"1.3","2%":"5.5","3%":"35.0","5%":"47.9","7%":"7.3","10%":"1.4","10-28%":"0.2","Timeout%":"0.0"}], "highlighted":{}}PKY_RESP_TIMENULL
please help me on above logic...