Skip to Content

Spliting string onto new line after every 132 characters in Data Services

Hi Guys,

I want to split string onto new line after every 132 characters.

here, for the product Pencil, the description length is more than 132 characters, hence after any complete word character, nearby to 132 character it shall split the string onto new line.

for more understanding of a problem I am sharing the screenshot below:

Kindly suggest.

Regards,

DS_Beginner

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 16, 2015 at 05:09 AM

    First add a column and calculate the maximum length of the text (say 150) . In the next query transform join the incoming source records with a row generation transform having max value as the max length. So you will get as many records rows for each record. In the third query transform where clause write this (ROWID - 1)* varcharlength < length (field)

    In the final query transform use a substring -

    substr(fieldname, 1+(ROWID-1)*varcharlength,varcharlength)

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 16, 2015 at 08:39 AM

    One query transform will do. Depending on the maximum lenght of your input field, add a 2nd, 3rd... field in the output. And map:

    • output_field_1 = substr(input_field, 1, 132)
    • output_field_2 = substr(input_field, 133, 132)
    • ...

    If you want your output in multiple rows instead of columns, add a Pivot transform. Refer to the Data Services Reference Guide for details.

    Add comment
    10|10000 characters needed characters exceeded