Search code examples
pentahokettlepdi

How to get the reorder the column with csv input fixed column in pentaho


Scenario:

I have created transformation to load data into table from csv file and I have following columns in csv file:

  1. Customer_Id
  2. Company_Id
  3. Employee_Name

But user may give input file with column ordering (random order) as

  1. Employee_Name
  2. Company_Id
  3. Customer_Id

so, if I try to load file which has random column ordering, will kettle load correct column values as per column names ... ?


Solution

  • Using ETL Metadata Injection you can use a transformation like this, to either normalize the data, or to store it to your database:

    Metadata transformation

    Then you just need to send the correct data to that transformation. You can read the header line from the CSV, and use Row Normaliser to convert to the format used by ETL Metadata Injection.

    I have included a quick example here: csv_inject on Dropbox, if you make something like this and run it from something that runs it per csv file it should work.