Reformatting rtf file to fixed number of characters per line

I would like to reformat a rtf file containing many lines of text to a fixed number of characters per line with a logical end of a word, and introduce a line feed or new line character \n at the end of each new line.

Is there a way of doing it in knime?

Hi @SridharVenu,

Iā€™d read in the whole file txt into one string and then run over the string and extract substrings with the length X, which is the maximum character number per line. If the substring ends with a whitespace or with a character after which a whitespace occurs it seems to be a word end and the substring seems good. If not and the end is in the middle of a word shift the index of the substring end further to the word end.

This all requires some Java or Python coding. There is no node that can do this out of the box.

Kind regards,
Janina

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.