Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I used the following code suggested in Talend documentation to retrieve a dynamic field value using tJavaRow.
Dynamic columns = row3.other;
for (int i = 0; i < columns.getColumnCount(); i++) {
DynamicMetadata columnMetadata = columns.getColumnMetadata(i);
System.out.println("Column Name = " + columnMetadata.getName());
System.out.println("Column Value = " + columns.getColumnValue(i));
}
In my case the column value is of type String. I want to replace the newline in the column value with a space.
I can use replace function in java. But to put the replaced string back to the Dynamic field is where I get lost.
is there any method that I can use put the string back to dynamic field? something like "setColumnValue"?
Also I couldn't find documentation for Dynamic and DynamicMetadata (routines.system.Dynamic and routines.system.DynamicMetadata). Can someone share the documentation link if they have please?
Thanks!
first: are you using dynamic column type.
if you know your column you do not need it.
If you are using it:
Dynamic columns = row3.other;
for (int i = 0; i < columns.getColumnCount(); i++) {
DynamicMetadata columnMetadata = columns.getColumnMetadata(i);
if (columnMetadata.getName().equals("yourColName"))
{columns.setColumnValue(i,columns.getColumnValue(i).replace("newline"," "))};
}
first: are you using dynamic column type.
if you know your column you do not need it.
If you are using it:
Dynamic columns = row3.other;
for (int i = 0; i < columns.getColumnCount(); i++) {
DynamicMetadata columnMetadata = columns.getColumnMetadata(i);
if (columnMetadata.getName().equals("yourColName"))
{columns.setColumnValue(i,columns.getColumnValue(i).replace("newline"," "))};
}
Hi,
Thanks for your reply. This works fine. I can now set the column value using setColumnValue(int, str).
Regards,
Ramya
In my use case i need to write the extracted field name and field value in a output file where we have 2 columns as schema i.e. fieldname and fieldvalue. How can i write all the column names and corresponding values in a file?