問題描述
我有一個(gè)具有以下結(jié)構(gòu)的csv文件,
i have csv file which having following structure.,
Alfreds,Centro,Ernst,Island,Bacchus
Germany,Mexico,Austria,UK,Canada
01,02,03,04,05
現(xiàn)在我必須將這些數(shù)據(jù)移動(dòng)到數(shù)據(jù)庫中,如下所示.
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
我嘗試映射這些列,但我無法按列提取數(shù)據(jù).
i try to map those colums but i can't able to extract the data in column wise.
這里我按列輸入數(shù)據(jù),但我需要在 SQLServer 中按行插入數(shù)據(jù)
Here my input data in column wise but i need to insert those in row wise in SQLServer
任何人都可以建議在 sql server 中將列數(shù)據(jù)轉(zhuǎn)換為行數(shù)據(jù)的方法嗎?.
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.
我在 ExtractText 中提取了 3 個(gè)輸入行作為 input.1,input.2,input.3.然后使用 表達(dá)式語言 并將其存儲(chǔ)在 "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".
使用循環(huán)概念通過使用Count"獲取第一列,然后在RouteOnAttribute中增加Count"檢查Count""le(totalcount)"
Using Loop Concept to get the first column by using "Count" and then increment "Count" Check "Count" in RouteOnAttribute "le(totalcount)"
現(xiàn)在使用 "Count" 屬性形成插入查詢.
Now form insert Query with "Count" Attribute.
它對(duì)我來說效果很好.它可能對(duì)某人有用.
It worked well for me.It could be useful for someone.
這篇關(guān)于如何在 NiFi 中映射流文件中的列數(shù)據(jù)?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!