版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bfhai/article/details/84074876
一、行转列
通过datastage实现输入数据如下:
REPID | last_name | Jan_sales | Feb_sales | Mar_sales |
---|---|---|---|---|
100 | Smith | 1234.08 | 1456.80 | 1578.00 |
101 | Yamada | 1245.20 | 1765.00 | 1934.22 |
输出数据如下:
REPID | last_name | Q1sales | Pivot_index |
---|---|---|---|
100 | Smith | 1234.08 | 0 |
100 | Smith | 1456.80 | 1 |
100 | Smith | 1578.00 | 2 |
101 | Yamada | 1245.20 | 0 |
101 | Yamada | 1765.00 | 1 |
101 | Yamada | 1934.22 | 2 |
作业实现如下:
(1)将测试数据写入测试文件
(2)通过Sequential File stage读取数据
(3)选择Pivot Enterprise stage,Sequential File stage的输出作为Pivot Enterprise stage的输入,同时Pivot Enterprise stage输出到另一个Sequential File stage中
(4)在Pivot Enterprise stage stage–>Properties中选择Horizontal
(5)在Pivot Enterprise stage stage–>Pivot Properties配置要转换的列及为转换后的列添加一个索引号
如上图所示
①勾选Pivot Index,此时会自动出现Pivot_index这一行
②手工添加转换后的字段pivotted,并设置字段类型,长度,精度
③双击pivotted行的Derivation处,或者单机下图标注的地方
添加需要转换的字段,点确定即可
(6)选择输出的字段
(7)运行程序,查看结果
作业下载位置
https://download.csdn.net/download/bfhai/10785308
也可以直接联系我获取