问题描述
我有一个csv文件,其结构如下.
i have csv file which having following structure.,
Alfreds,Centro,Ernst,Island,Bacchus
Germany,Mexico,Austria,UK,Canada
01,02,03,04,05
现在,我必须像下面那样将数据移到数据库中.
Now i have to move that data into database like below.
Name,City,ID
Alfreds,Germay,01
Centro,Mexico,02
Ernst,Austria,03
Island,UK,04
Bacchus,Canda,05
我尝试映射那些列,但是我无法按列提取数据.
i try to map those colums but i can't able to extract the data in column wise.
这里我的输入数据按列排列,但是我需要在SQLServer中按行插入这些记录
Here my input data in column wise but i need to insert those in row wise in SQLServer
有人可以建议在sql server中将按列数据传输到按行数据的方法吗?
Can anyone suggest way to transfer column wise data into row wise in sql server?.
谢谢
推荐答案
@Andy,
在NiFi中也可以不使用ExecuteScript而实现.
It could be possible in NiFi also without using ExecuteScript.
我已将3个输入行提取为ExtractText中的input.1,input.2,input.3.然后使用表达式语言并将其存储在"TotalCount" 属性中.
I have extract the 3 input rows as input.1,input.2,input.3 in ExtractText. And then count number of columns in "input.1" using AnydelinateValues in expression language and store that in "TotalCount" Attribute.
最初设为"Count = 1".
Initially made "Count=1".
使用循环概念通过使用"Count"来获取第一列,然后递增"Count",请在RouteOnAttribute中选中"Count""le(总数)"
Using Loop Concept to get the first column by using "Count" and then increment "Count" Check "Count" in RouteOnAttribute"le(totalcount)"
现在使用计数" 属性的表单插入查询.
Now form insert Query with "Count" Attribute.
对我来说效果很好.对某人可能有用.
It worked well for me.It could be useful for someone.
这篇关于如何在NiFi中映射流文件中的列明智数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!