Search code examples
javaoracle-databaseexceletltalend

How to break string from an excel file into substrings and load it?


I'm actually working on a talend job. I need to load from an excel file to an oracle 11g database.

I can't figure out how to break a field of my excel entry file within talend and load the broken string into the database.

For example I've got a field like this:

toto:12;tata:1;titi:15

And I need to load into a table, for example grade:

| name | grade |
|------|-------|
| toto |12     |
| titi |15     |
| tata |1      |
|--------------|

Thank's in advance


Solution

  • In a Talend job, you can use tFileInputExcel to read your Excel file, and then tNormalize to split your special column into individual rows with a separator of ";". After that, use tExtractDelimitedFields with a separator of ":" to split the normalized column into name and grade columns. Then you can use a tOracleOutput component to write the result to the database.

    While this solution is more verbose than the Java snippet suggested by AlexR, it has the advantage that it stays within Talend's graphical programming model.