- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Separate CSV column by delimiter or whitespace
- Labels:
-
Apache NiFi
Created ‎08-31-2022 12:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a csv where one of the columns can sometimes come as a pair such as:
Column_name |
1 , 2 |
2.5 3.2 |
2.9 - 3.2 |
The delimiter can potentially be anything really, but there will be a delimiter. Also the values will only come as pairs.
My question is, is there an efficient way to separate this one column into a flowfile where each value has it's own column, such that I have the following result:
Column #1 | Column #2 |
1 | 2 |
2.5 | 3.2 |
Thank you
Created ‎08-31-2022 03:02 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
Not sure if this is possible with out of the box processor. I can think of ReplaceText first to replace different delimiters like (-) or white-space (\s) to common delimiter like (,) however if there is a white space before or after other delimiters like (-) or (,) its not going to work. Another option is to use ExecuteScript processor where you try to read each line (after the header) from the flowfile content and then use string split function and try it with different delimiter, once you get two array elements you construct your new string with the new column header and delimiter and transfer to the success relationship.
