Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
lcupito
Contributor
Contributor

Add a header from a context or another file

Hi everyone,

i had a problem adding a header in a dynamic file.

I previously processed a file and in the output of the tjavarow I have the out field with the OBJECT type. I tried to insert it in the tjavarow but it prints the header for each row. However, the created file has no header. How do I add the header that I saved as context or as a column of another file?

0695b00000qPn5EAAS.png

Labels (5)
5 Replies
Anonymous
Not applicable

Hi

Hope this KB article is helpful for you, it shows how to update the column properties including the column name when using Dynamic schema.

https://community.talend.com/s/article/Updating-column-properties-when-using-Dynamic-schema

 

Regards

Shong

lcupito
Contributor
Contributor
Author

It's not for me, but thank you anyway.

Anonymous
Not applicable

can you show us the java code on tJavaRow? If I understand your requirement well, you need to access the column properties, get the column name and replace it with new name from context variable.

 

lcupito
Contributor
Contributor
Author

This is my tJavaRow code:

 

String[] headers = context.W_INTESTAZIONE.split("\\|");

 

String result = "";

 

for (String header: headers) {

 

 Object columnValue = input_row.data.getColumnValue(header);

 

 if (columnValue != null) {

 

  result += columnValue.toString() + "|";

 

 } else {

 

  result += "null|";

 

 }

 

}

 

if (result.endsWith("|")) {

 

 result = result.substring(0, result.length() - 1);

 

}

 

output_row.out = result;

 

In context.W_INTESTAZIONE.split("\\|") i have the headers passed from father job (column1|column2|column3 etc etc) and in output (Object datatype) i have only the value without headers. i need as a first row the header and the value after the first row.

CMolloy1698391524
Contributor
Contributor

Thank you for the article link, you made my day 😊