Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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
It's not for me, but thank you anyway.
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.
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.
Thank you for the article link, you made my day 😊