Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

1 record is comprised of 2 rows - require 1 row in output

Hi, I am new to Talend. I am using it to parse financial files into something that is in a 'DB insert' - ready state. It is most likely exported from PDF to Excel by my source. 

 

Anyhow the records I get are of format : 

Group A Header

record1 someinfoA

record1_id someinfoB

record2 someinfoC

record2_id someinfoD

Group B Header etc etc 

 

The output I want is :

record1 record1_id someinfoA "Group A Header" someinfoB

record2 record2_id someinfoC "Group A Header" someinfoD

 

so I want to merge the data in the record pair as well as adding in the group header into the record. There is nothing to join the pair except that in the extract the format of a record is a line 1 and a line 2!

 

Any ideas would be really appreciated!

 

Labels (2)
14 Replies
Anonymous
Not applicable
Author

What code do you have in your tJavaRow component?

Anonymous
Not applicable
Author

Here is the code I had in there. But why would a tJavaRow component being added to the end effect the first part of the job running. Would it not just run as it had up to that component and then have an issue?

 

if (input_row.Quantity.equals("")||input_row.Quantity == null) { //CCP Group Header encountered
context.Temp_CCP = input_row.Description; //capture CCP
output_row.Description = input_row.Description;
output_row.Quantity = new BigDecimal(0);
output_row.Currency = "";
output_row.Base_Cost = null;
output_row.Base_MV = null;
output_row.CCP = "";
output_row.Reference = "";
}
else if (!input_row.Quantity.equals("Per Share:") && !input_row.Quantity.equals("")) { //part1of2ofrecord encountered
context.Reference = input_row.Description; //capture Desc
output_row.Description = input_row.Description;
output_row.Quantity = new BigDecimal(input_row.Quantity);
output_row.Currency = ""; //not used
output_row.Base_Cost = input_row.Base_Cost;
output_row.Base_MV = input_row.Base_MV;
output_row.CCP = context.Temp_CCP;
output_row.Reference = "";
}
else if (input_row.Quantity.equals("Per Share:")) { //part2of2ofrecord encountered
output_row.Description = input_row.Description;
output_row.Quantity = new BigDecimal(0);
output_row.Currency = input_row.Currency;
output_row.Base_Cost = null; //not used
output_row.Base_MV = null; //not used
output_row.CCP = context.Temp_CCP;
output_row.Reference = context.Reference;
}
else {} //should only be 3 scenarious above

Anonymous
Not applicable
Author

From the look of your job, I would say that the IF condition needs changing. Use the following code to see in your job what the data you are working with actually looks like when it gets to the tJavaRow....

 

System.out.println(input_row.Quantity);
Anonymous
Not applicable
Author

Thank you, printing these out really helped seeing what was null etc. 

 

So have gotten this nearly working by reading the header, putting it in a context param, reading part 1/2, and adding in context param and setting a reference context param. I ready 2/2 and add in the 2 context params I just mentioned. Now I will do a join to add all the part 1s to the part 2 of the record. I utilised tJavaRow.  

 

Also it really helped me to know that tJavaRow had to be connected to something to work properly/test. 

Anonymous
Not applicable
Author

My solution was to read the header and save in context variable. Read record 1/2 and save values in the context parameters. Then I read record 2/2 and stamp the context parameters on the end of the record. I did this in a tJavaRow. Then I used a tmap to clean things up.