问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/42347666/how-to-split-this-csv-file-into-multiple-contents