使用SSIS格式化.csv文件

时间:2017-10-11 18:46:19

标签: csv ssis pivot ssis-2012

我有这样的.csv文件:

+---------+--------+--------------------+---------+-----+----------+----------------+
| CLIENTE | CENTRO |      MATERIAL      | PERIODO | MES | UNIDADES |   PLATAFORMA   |
+---------+--------+--------------------+---------+-----+----------+----------------+
|  100013 |   2001 | 1A000-991801053303 |    2017 |   1 |      100 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |   2 |      200 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |   3 |      300 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |   4 |      400 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |   5 |      500 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |   6 |      600 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |   7 |      700 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |   8 |      800 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |   9 |      900 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |  10 |     1000 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |  11 |     1100 | F25 -( BMW X3) |
|  100013 |   2001 | 1A000-991801053303 |    2017 |  12 |     1200 | F25 -( BMW X3) |
+---------+--------+--------------------+---------+-----+----------+----------------+

我读取它没有平面文件源的问题,最后发送到ADO NET Destination。问题是我们的客户想要读取其他方式的寄存器。他们的.csv文件格式如下:

+---------+--------+--------------------+----------------+--+----------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| CLIENTE | CENTRO |      MATERIAL      |   PLATAFORMA   |  |  2017-1  | 2017-2  | 2017-3  | 2017-4 | 2017-5  | 2017-6  | 2017-7  | 2017-8  | 2017-9  | 2017-10 | 2017-11 | 2017-12 |
+---------+--------+--------------------+----------------+--+----------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |      100 |     200 |     300 |     400 |     500 |     600 |     700 |     800 |     900 |    1000 |    1100 |    1200 |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
|  100013 |   2001 | 1A000-991801053303 | F25 -( BMW X3) |  |          |         |         |         |         |         |         |         |         |         |         |         |
+---------+--------+--------------------+----------------+--+----------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+

第五列的第一个寄存器:2017-10100对应于另外4列2017-11200的第一行到第二行,依此类推...... < / p>

正如您所看到的,前4列是相同的,但第5列则不是。它们合并了列PERIODOMES,在它下面我们有列UNIDADES。我想要的是如何格式化它.csv和格式为第一个。

总而言之,我想将第二个.csv文件转换为第一个

我读到我可以使用PIVOT实现它。但我真的不明白如何使用它。我搜索关于它的教程,我没有发现任何类似的事情。

实际SSIS包:

Package

1 个答案:

答案 0 :(得分:0)

使用Unpivot转换。来自VS BIDS 2008的这张图片。 然后,您可以使用pivotkey值在目标表中创建行 enter image description here