Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have created an ETL job that reads an excel file sheet and writes the content of the sheet to a CSV file. As I don't know the schema of the sheet at the time of reading the file, I use "Dynamic" schema.
The excel file I read has newline characters in some columns which is causing an issue while reading later in the job the generated CSV file from it.
Is there a way to remove/replace new line characters while reading an excel file using tFileInputExcel component with schema specified as "Dynamic"?
Got a way to do it!
I simply put a tJavaRow component between the input and output components.
And in the java component put the following code:
routines.system.Dynamic dynamic = input_row.newColumn; for (int colIdx = 0; colIdx < dynamic.getColumnCount(); colIdx++) { Object dynamicValue = dynamic.getColumnValue(colIdx); if (dynamicValue instanceof String) { String stringValue = (String)dynamicValue ; stringValue = stringValue.replaceAll("\\n", "|"); dynamic.setColumnValue(colIdx, stringValue); } } output_row.newColumn = dynamic;
And it's done!
Got a way to do it!
I simply put a tJavaRow component between the input and output components.
And in the java component put the following code:
routines.system.Dynamic dynamic = input_row.newColumn; for (int colIdx = 0; colIdx < dynamic.getColumnCount(); colIdx++) { Object dynamicValue = dynamic.getColumnValue(colIdx); if (dynamicValue instanceof String) { String stringValue = (String)dynamicValue ; stringValue = stringValue.replaceAll("\\n", "|"); dynamic.setColumnValue(colIdx, stringValue); } } output_row.newColumn = dynamic;
And it's done!
Thanks @fdenis Iused tJavaRow instead of tJavaFlex.