Sam Keith
Sam Keith

Reputation: 359

Kettle Load csv data into multiple tables

I need to load 2 database tables from a single csv file containing mixed data. I also want to maintain parent child relations using foreign key relation.

Below is example of input csv file,

<name>,<title>,<department>,<location>
John,Developer,IT, Florida
Mike,Designer,Sales,Nevada
Chris,Designer,Sales,Nevada

And below are 2 table structures. Employee table has dept_id as foreign key. Department table will have unique names(no repetitions). According to above sample csv, it should have 2 entries(IT, Sales).

DEPARTMENT
-------------
id
name
location


EMPLOYEE
---------
id
name
title
dept_id

I am a completely new to using Kettle and any pointers would be appreciated.

Upvotes: 3

Views: 2724

Answers (1)

Codek
Codek

Reputation: 5164

This is very easy. Have you downloaded spoon and started it up yet (The editor for creating transformations)

  1. Create a text file input
  2. Copy the data from text file input to a group by step to group by department, and then to an insert/update step to get your DEPARTMENT table
  3. Copy the data from text file input to another insert/update table step to create your employee table

As for the ID's you can allow the database to generate those as autonumber fields if you like - and do the lookup on whatever the unique requirement is.

I strongly reccomend downloading the tool and having a play - it's so easy once you start.

Upvotes: 1

Related Questions