Comments and answers for "WordWrapper 2.0?" https://knowledge.safe.com/questions/37001/wordwrapper-20.html The latest comments and answers for the question "WordWrapper 2.0?" Comment by peteralstorp on peteralstorp's comment https://knowledge.safe.com/comments/37052/view.html 完美,绝对会使用包装器again soon. Thanks!

Tue, 29 Nov 2016 09:52:01 GMT peteralstorp
Comment by david_r on david_r's comment https://knowledge.safe.com/comments/37048/view.html Done: https://hub.safe.com/transformers/textwrapper

Let me know if anything is unclear.
Tue, 29 Nov 2016 08:41:05 GMT david_r
Comment by takashi on takashi's comment https://knowledge.safe.com/comments/37043/view.html oops, I overlooked @Mark2AtSafe's comment. Good to hear that the request has been filed already.
Tue, 29 Nov 2016 04:32:34 GMT takashi
Comment by takashi on takashi's answer https://knowledge.safe.com/comments/37042/view.html Maybe this update works with FME 2016.1.3: b16709-wordwrapper-v2-beta.fmw
Hi @DanAtSafe, please update the WordWrapper in the Hub.
Tue, 29 Nov 2016 03:38:18 GMT takashi
Comment by rylanatsafe on rylanatsafe's answer https://knowledge.safe.com/comments/37037/view.html @david_r - Fantastic! I'm glad to see that you have found a fix for this custom transformer! This would be a major change in the behind-the-scenes functionality from when it was first created (and last updated) in FME 2012.

I would like to encourage you to submit this as a new custom transformer to FME Hub, e.g. TextWrapper, and we can deprecate the WordWrapper.
Mon, 28 Nov 2016 23:56:39 GMT rylanatsafe
Comment by david_r on david_r's answer https://knowledge.safe.com/comments/37014/view.html Yes, but it doesn't work (as it should) in FME 2016.

Mon, 28 Nov 2016 17:03:17 GMT david_r
Answer by itay https://knowledge.safe.com/answers/37013/view.html

It still there on the FME hub

Mon, 28 Nov 2016 17:02:21 GMT itay
Comment by david_r on david_r's comment https://knowledge.safe.com/comments/37009/view.html That's good to hear. Feel free to borrow bits of the code below if you decide to port it to Python.
Mon, 28 Nov 2016 16:34:56 GMT david_r
Comment by mark2atsafe https://knowledge.safe.com/comments/37007/view.html fyi I filed a request to get the WordWrapper fixed. It's PR#74183

Mon, 28 Nov 2016 16:30:24 GMT mark2atsafe
Comment by peteralstorp on peteralstorp's answer https://knowledge.safe.com/comments/37006/view.html Blessed be the force of the Knowledge center! Thank you, David!

Mon, 28 Nov 2016 16:26:51 GMT peteralstorp
Answer by david_r https://knowledge.safe.com/answers/37005/view.html

I posted this a long time ago, but it's not easily searchable and the code has been mangled while ported between the different versions of the forum software, so here's a slightly modified version of my original post.

You can insert the following code into a PythonCaller, it will read a string from the attribute "text_line_data" and wrap it at the position specified in a parameter "MaxWidth":

import fmeobjects import textwrap def TextWrapper(feature): text = feature.getAttribute("text_line_data") # modify as necessary maxLength = int(FME_MacroValues['MaxWidth']) parts = textwrap.wrap(text, maxLength) feature.setAttribute('number_of_parts', len(parts)) if parts: feature.setAttribute('parts{}', parts) 

Expose the attributes "parts{}" and "number_of_parts" in the PythonCaller.

This outputs all parts to the list "parts{}", you can then use a ListExploder to get one feature per wrapped line, see attached sample workspace.

textwrapper.fmwt

Mon, 28 Nov 2016 16:17:44 GMT david_r
Answer by corrado https://knowledge.safe.com/answers/37003/view.html

It seem you need "SubstringExtractor" transformer.

Mon, 28 Nov 2016 16:14:14 GMT corrado