Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
please could you help me split a long string more than 50 char from input to 2 columns in output. the output should be splitted so the columns should make sense.
input :
company_name = "i am new to talend and want to learn, it great tool for data integration"
output:
row1.company_name1 = i am new to talend and want to
row1.Company_Name2 = learn, it great tool for data integration
Regards,
Probably due to null values on fields.
Try this:
String[] arr = input_row.col1.split(" ");
output_row.input_row.Company_Name = "";
output_row.input_row.Company_Name1 = "";
for (String word : arr) {
if ((output_row.Company_Name.length() + word.length() + 1) < 50)
output_row.Company_Name = output_row.Company_Name + " " + word;
else
output_row.Company_Name1 = output_row.Company_Name1 + " " + word;
}
if ((output_row.Company_Name1.length() < 1)
output_row.Company_Name1 = null;
The problem is on the tFileExcelInput component which gives you no rows.
fixed the tFileExcelInput , but still below error.
not sure if tjavarow is in right place and the code in it.
input row column name is "input_row.Company_Name" I want to split it to "output_row.Company_Name" and "output_row.Company_Name1"
output_row.Company_Name can have max 50 char.
Probably due to null values on fields.
Try this:
String[] arr = input_row.col1.split(" ");
output_row.input_row.Company_Name = "";
output_row.input_row.Company_Name1 = "";
for (String word : arr) {
if ((output_row.Company_Name.length() + word.length() + 1) < 50)
output_row.Company_Name = output_row.Company_Name + " " + word;
else
output_row.Company_Name1 = output_row.Company_Name1 + " " + word;
}
if ((output_row.Company_Name1.length() < 1)
output_row.Company_Name1 = null;
perfect works fine.
Great!