Viktor Carlson
Viktor Carlson

Reputation: 1008

TalendOpenStuido DI Replace content of one column of .slx File with another column of .csv file

I have two input files:

  1. an .xlsx file that looks like this:

enter image description here

  1. an .csv files that looks like this:

enter image description here

I already have a talend job that transforms the .xlsx file into an .xml file. One node in the .xml file contains the <stockLocationCode>SL213</stockLocationCode>

The output .xml file looks like this: enter image description here

Now I need to replace every occurence of the stockLocationCode with the second column of the .csv file. In this case the result would be: enter image description here

My talend job looks like this:

enter image description here

I use a tMap component to put the columns of the .xlsx file into the right node of the output xml file.

But I do not know how I can peplace the StockLocactionCode with the acutal full stock location using the .csv file. I tired to also map the .csv file with the tMap component.

I would neet to build in a methof that looks at the current value of the node <stockLocationCode> and loops over the whole .csv file until it find it in the first column of the .csv file and then replace the <stockLocationCode> content with the content of the second column of the .csv file.

Performance is not important ;)

Upvotes: 0

Views: 72

Answers (2)

tobi6
tobi6

Reputation: 8239

  • First, you'll need a lookup in e.g. a tMap or tXMLMap component, where you map your keys and add a new column with the second column of the csv file
  • The resulting columns would look like this:

Product; Stock Location Code; CSV 2nd column data

  • Now in a second map you could just remove the stock location code and do the rest of your job.

Voila, you exchanged the columns.

Upvotes: 1

PreetyK
PreetyK

Reputation: 451

u can use tXMLMap which lookup

Upvotes: 0

Related Questions