Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Can NiFi extract rows of data from csv files etc?

Highlighted

Can NiFi extract rows of data from csv files etc?

Expert Contributor

Hi, i am very new to NiFi and following some tutorials, but most deal with json and xml. Can NiFi extract rows of data from files such as csv etc. For example if i wanted to extract row 2 which has a header longitude and row 3 with a header latitude.

Thank You.

3 REPLIES 3

Re: Can NiFi extract rows of data from csv files etc?

Expert Contributor

@Roger Young since your csv seems to be of fixed columns, you can use an combination of Replace and Extract text.

You can use one the example template here which converts csv to json, the first step is what you need.

https://cwiki.apache.org/confluence/download/attachments/57904847/CsvToJSON.xml?version=1&modificati...

https://cwiki.apache.org/confluence/display/NIFI/Example+Dataflow+Templates

Re: Can NiFi extract rows of data from csv files etc?

Expert Contributor

Hi, i was trying that template yesterday but didnt fully understand what it was doing by replacing, extracting and replacing text. It worked on the headers of the csv, but it didnt convert the rows of integers under the headers. I am trying to extract a row, the header which will be text and then the rows under that header which will be integers

Re: Can NiFi extract rows of data from csv files etc?

Expert Contributor
@Roger Young

Assuming you are using a file on the file system you should be doing the following.

you could use "split text processor" after fetcing the file, to split into single lines and then process as needed further as needed.