Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Separate CSV column by delimiter or whitespace

avatar
Explorer

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 #1Column #2
12
2.5 3.2

 

Thank you

1 REPLY 1

avatar

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.