How to map the column wise data in flowfile in NiFi?(如何在 NiFi 中映射流文件中的列数据?)
问题描述
我有一个具有以下结构的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.
我在 ExtractText 中提取了 3 个输入行作为 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"获取第一列,然后在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)"
现在使用 "Count" 属性形成插入查询.
Now form insert Query with "Count" Attribute.
它对我来说效果很好.它可能对某人有用.
It worked well for me.It could be useful for someone.
这篇关于如何在 NiFi 中映射流文件中的列数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 NiFi 中映射流文件中的列数据?
基础教程推荐
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 无法解决整理冲突 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 在 SQL 中连接多个表 2021-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
