SSIS将列转换为Excel工作表中的行

时间:2017-01-24 14:31:18

标签: excel ssis

我有一个excel表格,其结构如下:

+------------+-----+----------+----------+------------------+------------------+------------------+------------------+------------------+------------------+----------------+----------------+------------------+------------------+------------------+------------------+------------------+------------------+----------------+----------------+
|    date    | Day | StoreDdg | StoreR/H | DbgCategory1Dpt1 | R/HCategory1Dpt1 | DbgCategory2Dpt1 | R/HCategory2Dpt1 | DbgCategory3Dpt1 | R/HCategory2Dpt1 | DbgDepartment1 | R/HDepartment1 | DbgCategory1Dpt2 | R/HCategory1Dpt2 | DbgCategory2Dpt2 | R/HCategory2Dpt2 | DbgCategory3Dpt2 | R/HCategory2Dpt2 | DbgDepartment2 | R/HDepartment2 |
+------------+-----+----------+----------+------------------+------------------+------------------+------------------+------------------+------------------+----------------+----------------+------------------+------------------+------------------+------------------+------------------+------------------+----------------+----------------+
| 1-Jan-2017 | Sun |  138,894 | 133%     |              500 | 44%              |           12,420 | 146%             |                  |                  |                |         11,920 | 104%             | #DIV/0!          |           13,580 | 113%             |            9,250 | 92%              |          6,530 | 147%           |
| 2-Jan-2017 | Mon |  138,894 | 270%     |              500 | 136%             |           12,420 | 277%             |           11,920 |                  |                |                | 193%             | #DIV/0!          |           13,580 | 299%             |            9,250 | 225%             |          6,530 | 181%           |
+------------+-----+----------+----------+------------------+------------------+------------------+------------------+------------------+------------------+----------------+----------------+------------------+------------------+------------------+------------------+------------------+------------------+----------------+----------------+

我想将其转换为

+------------+-----+--------+-------------+---------------+---------+------+
|    date    | Day | Store  | Department  |   Category    |   Dpt   | R/H  |
+------------+-----+--------+-------------+---------------+---------+------+
| 1-Jan-2017 | Sun | Store1 | Department1 | Category1Dpt1 | 138,894 | 133% |
| 1-Jan-2017 | Sun | Store1 | Department1 | Category2Dpt1 |     500 | 44%  |
| 1-Jan-2017 | Sun | Store1 | Department1 | Category3Dpt1 |  12,420 | 146% |
| 1-Jan-2017 | Sun | Store1 | Department2 | Category1Dpt2 |  11,920 | 104% |
| 1-Jan-2017 | Sun | Store1 | Department2 | Category2Dpt2 |  13,580 | 44%  |
| 1-Jan-2017 | Sun | Store1 | Department2 | Category3Dpt2 |   9,250 | 92%  |
| 2-Jan-2017 | Mon | Store1 | Department1 | Category1Dpt1 | 138,894 | 270% |
| 2-Jan-2017 | Mon | Store1 | Department1 | Category2Dpt1 |     500 | 136% |
| 2-Jan-2017 | Mon | Store1 | Department1 | Category3Dpt1 |  12,420 | 277% |
| 2-Jan-2017 | Mon | Store1 | Department2 | Category1Dpt2 |  13,580 | 299% |
| 2-Jan-2017 | Mon | Store1 | Department2 | Category2Dpt2 |   9,250 | 225% |
| 2-Jan-2017 | Mon | Store1 | Department2 | Category3Dpt2 |   6,530 | 181% |
+------------+-----+--------+-------------+---------------+---------+------+

关于如何做到这一点的任何建议?

2 个答案:

答案 0 :(得分:0)

您可以将excel文件作为源来执行此操作。您可能必须以2005或2007格式保存为excel,具体取决于您使用Visual Studio的版本,如果它已经是2007格式,那么它就是好的。

现在提取DbgDepartment1和DbgDepartment2的数据,您可以在DFT中创建2个不同的源。在一个中,您可以选择与DbgDepartment1相关的列,在第二个中,您可以选择DbgDepartment2。您可能必须使用派生列,具体取决于您将进一步使用的逻辑。然后你可以使用Union Transformation,因为源文件是相同的,可以将数据加载到目的地。试试看,你会得到一个解决方案。

答案 1 :(得分:0)

我使用R统计语言通过使用数据整理包来解决这个问题(" tidyr"," devtools")

了解更多信息,请查看链接:http://garrettgman.github.io/tidying/