当前位置:网站首页>Kettle实验 转换案例
Kettle实验 转换案例
2022-04-23 09:07:00 【风梳烟】
1.转换案例
最容易实现的简单案例就是生成随机数,并存储到txt文件 新建一个转换保存为test_random(后缀为.ktr) 通过拖拽插件方式,在核心对象->输入和输出分别拖拽“生成随机数”和“文本文件输出”两个按钮, 然后点击“生成随机数”并按下shift键,用鼠标指向“文本文件输出”,以生成剪头,表示数据流向。如下图:



编辑输入流,即“生成随机数”按钮,如图所示

2. 转换案例
然后编辑输出流,即“文本文件输出”按钮,如图所示

查看结果,如图所示
3.正式实验
通过上述简单实验,我们知道了输入输出流的基本操作,接下来我们进入正式实验
1)将上述实验中的输入输出全部改为Excel。进行相关配置说明如下: Excel输入:
在文件选项下,表格类型根据实际进行适配(xls or xlsx),在文件或目录后,点击“浏览”选择自己的源数据文件,然后点击“添加”;
在工作表选项下,点击“获取工作表名称...”添加工作表,即Excel中的sheet1;

在字段选项下,点击“获取来自头部数据的字段...”自动获取字段,由于原Excel中整型数据转入会变成浮点型,所以需要进行更改,如图所示:

1)将上述实验中的输入输出全部改为Excel
进行相关配置说明如下: Excel输出:只需要配置输出文件名即可,其他均为默认。

2)下来需要处理的就行核心步骤,即转换。首先针对生成数据1进行分析,由于kettle中分组需要首先进行排序,从而需要处理的点有:
(1)将挂号日期时间截取到日;
(2)对年龄按照一定标准进行转换(自己定义);
(3)按照待分组的字段进行排序;
(4) 进行分组统计。 按照上述思路,在“转换”和“统计”核心对象中,分别找到对应组件,完成基本数据流节点配置,如图所示:

在“字段选择”组件中,对时间进行处理。 在元数据选项中,需要对Date进行转换成String,格式设置为yyyy-MM-dd,同时可以对字段进行更名操作。 另外还可以对字段进行选择,修改,移除。如图所示:

3)在“数值范围”组件中,对年龄进行处理,划分标准自己定义,如图所示:

4)在“排序记录”组件中,按照生成数据要求,需要对日期,性别,年龄段进行排序,如图所示:
5)在“分组”组件中,进行分组统计,如图所示:

6)执行,结果如图所示:
版权声明
本文为[风梳烟]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_56814370/article/details/123430964
边栏推荐
- Taxable income
- js 原型链的深入
- Latex paper typesetting operation
- Data visualization: use Excel to make radar chart
- PLC point table (register address and point table definition) cracking detection scheme -- convenient for industrial Internet data acquisition
- 2022-04-22 openebs cloud native storage
- Research purpose, construction goal, construction significance, technological innovation, technological effect
- 112. 路径总和
- valgrind和kcachegrind使用運行分析
- Open services in the bottom bar of idea
猜你喜欢

Introduction to GUI programming swing

资源打包关系依赖树

【SQL server速成之路】数据库的视图和游标

Resource packaging dependency tree

Automatic differentiation and higher order derivative in deep learning framework

Redis Desktop Manager for Mac

Share the office and improve the settled experience

How to protect open source projects from supply chain attacks - Security Design (1)

LLVM之父Chris Lattner:编译器的黄金时代

MySQL小练习(仅适合初学者,非初学者勿进)
随机推荐
Redis Desktop Manager for Mac
web页面如何渲染
Machine learning (VI) -- Bayesian classifier
On array replication
Resource packaging dependency tree
Non duplicate data values of two MySQL query tables
L2-024 部落 (25 分)(并查集)
【原创】使用System.Text.Json对Json字符串进行格式化
Flink同时读取mysql与pgsql程序会卡住且没有日志
Program, process, thread; Memory structure diagram; Thread creation and startup; Common methods of thread
Employee probation application (Luzhou Laojiao)
The most concerned occupations after 00: civil servants ranked second. What was the first?
Find the sum of simple types of matrices
错误: 找不到或无法加载主类
Output first order traversal according to second order and middle order traversal (25 points)
RSA 加密解密签名验签
Thread scheduling (priority)
The crawler returns null when parsing with XPath. The reason why the crawler cannot get the corresponding element and the solution
LeetCode_ DFS_ Medium_ 1254. Count the number of closed islands
What is augmented reality technology? Where can it be used?