如何将此csv文件拆分为多个内容? [英] How to split this csv file into multiple contents?

查看:34
本文介绍了如何将此csv文件拆分为多个内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包含以下内容的 CSV 文件,Input.csv

 下面的示例 NiFi 数据演示截止日期 20-02-2017,23-03-2017My Input No1 inside csv,,,,,,,动物,今天-20.02.2017,昨天-19-02.2017福克斯,21,32狮子,20,12My Input No2 inside csv,,,,姓名、身份证、城市Ma12,英国和,21,美国Prabh,32,LI

我需要将整个 csv(Input.csv) 分成两部分,如 InputNo1.csv 和 InputNo2.csv.

对于 InputNo1.csv 应该只有以下内容.,动物,今天-20.02.2017,昨天-19-02.2017福克斯,21,32狮子,20,12对于 InputNo2.csv 应该有以下内容.,姓名、身份证、城市Ma12,英国和,21,美国Prabh,32,LI

是否可以使用现有处理器将 csv 转换为 NiFi 中的多个部分?

解决方案

是的.

使用 ReplaceText 处理器删除全局头,使用 SplitContent 将生成的流文件拆分为多个流文件,使用另一个 ReplaceText 删除剩余的注释字符串,因为 SplitContent 需要一个文字字节字符串,而不是正则表达式,然后执行正常的 SplitText 操作.

这是一个

I have CSV File which having below contents, Input.csv

 Sample NiFi Data demonstration for below
Due dates 20-02-2017,23-03-2017

My Input No1 inside csv,,,,,,
Animals,Today-20.02.2017,Yesterday-19-02.2017
Fox,21,32
Lion,20,12
My Input No2 inside csv,,,,
Name,ID,City
Mahi,12,UK
And,21,US

Prabh,32,LI

I need to split above whole csv(Input.csv) into two parts like InputNo1.csv and InputNo2.csv.

For InputNo1.csv should have below contents only.,

Animals,Today-20.02.2017,Yesterday-19-02.2017
Fox,21,32
Lion,20,12

For InputNo2.csv should have below contents.,

Name,ID,City
Mahi,12,UK
And,21,US

Prabh,32,LI

Is this possible to convert csv into Multiple parts in NiFi possible with existing processors?

解决方案

Yes.

Use the ReplaceText processor to remove the global header, use SplitContent to split the resulting flowfile into multiple flowfiles, use another ReplaceText to remove the leftover comment string because SplitContent needs a literal byte string, not a regex, and then perform the normal SplitText operations.

Here is a template specific to the input you provided in your question.

这篇关于如何将此csv文件拆分为多个内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆