pentaho DI Tutorial (spoon)

Pentaho Data Integration (PDI, also called Kettle),是pentaho的etl工具.虽然etl工具一般都用在数据仓库环境中,可是,PDI还是可以做以下事情:

1)在数据库或应用系统间迁移数据.

2)把数据导成为检系统

3)大数据的批量倒入数据库。

4)系统整合。

5)数据清洗。

PDI的使用非常简单,每一步基本上都可以听过图形化的工具来完成,而不需要写代码。从这个意义上说,PDI是面向元数据的。

PDI既可以作为一个单独工具使用,也可以作为pentaho的整个软件包的一部分使用。作为一个单独的工具,PDI支持各种数据源的输入和输出,包括:

文本文件;数据表;各种商业化的数据库引擎。PDI允许你对数据进行各种精细的控制。

现在,我们通过传统的“Hello world”的例子,来展示使用PDI是多么的简单。

1)下载PDI;

2)spoon的简介:

spoon是一个图形化的工具,用来设计和测试PDI要使用的过程等。设计测试完毕后,可以在终端窗口运行。

In Spoon, you build Jobs and Transformations. PDI offers two methods to save them:

  1. Database repository
  2. Files

3)例子

 a)源数据是一个csv文件,内容如下:

    last_name, name
Suarez,Maria
Guimaraes,Joao
Rush,Jennifer
Ortiz,Camila
Rodriguez,Carmen
da Silva,Zoe

b)经过转换后,变为xml文件,期望值如下:

- <Rows>
  - <row>
        <msg>Hello, Maria!</msg>
    </row>
  - <row>
        <msg>Hello, Joao!</msg>
    </row>
  - <row>
        <msg>Hello, Jennifer!</msg>
    </row>
  - <row>
        <msg>Hello, Camila!</msg>
    </row>
  - <row>
        <msg>Hello, Carmen!</msg>
    </row>
  - <row>
        <msg>Hello, Zoe!</msg>
    </row>
  </Rows>

下面是具体操作:

 第一步:菜单选择:文件--〉新建--〉转换

第二步:设置。对转换过程进行设置。如上图。

命名并保存。

使用 Steps and Hops构建转换的骨架。

  在转换里面:step是最小的单元步骤。step的种类非常繁多,基本上,可以归纳成几类,比如input和output,还有其他归类。每一个step都认为是

完成一个工作,比如恢复数据集合等。

而hop,是在两个step之间数据转换流动的图示。包含数据的起始和传递方向。

我们这次转换例子,包含三个步骤:

1)读取csv文件。

2)加入问候语句。

3)存成xml文件。

  • To the left of the workspace is the Steps Palette. Select the Input category.
  • Drag the CSV file onto the workspace on the right.
  • Select the Scripting category.
  • Drag the Modified JavaScript Value icon to the workspace.
  • Select the Output category.
  • Drag the XML Output icon to the workspace.

下面,选择第一个step,按住shift键,拖到第二个step上。

同样操作第二个到第三个。

现在,配置第一个step,双击它。可以看到:

这里还有2个步骤:get fields,和preview。

原文地址:https://www.cnblogs.com/aomi/p/3082505.html