We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

split a large chunk of data into 32 char meaningful strings

pchi
5 - Atom

I want to split a large chunk of data into 32 char meaningful strings.
Intrepid Air and Space Museum of ny 46th St And 12th Ave Pier 86 New York City, NY 10036 into  3 chunks without breaking a work.
Intrepid Air and Space Museum, of ny 46th St And 12th Ave Pier, 86 New York City NY 10036

6 REPLIES 6
pchi
5 - Atom

INPUT : Impact Christian Church of Woodland Park Colorado Scott Park

EXPECTED OUTPUT: 
Impact Christian Church of
Woodland Park Colorado Scott Park

BS_THE_ANALYST
15 - Aurora
15 - Aurora

@pchi tricky problem. 

This should satisfy what you're after using Regex. You can see the solution visually here: https://regex101.com/r/ZAcStF/2 

(.{1,32}\b\S*)

Explanation:

  • .{1,32}: This captures up to 32 characters.
  • \b\S*: This part captures the rest of the word if the previous match ends mid-word.

The combined expression ensures that we finish capturing the whole word without restricting the character count strictly to 32 characters.

Workflow attached, and here's a sneak peak:

Screenshot 2024-10-05 174609.png

 

Any questions, @ me so I get notified.

All the best,

BS

All the best,
BS

LinkedIN

Bulien
BS_THE_ANALYST
15 - Aurora
15 - Aurora

@pchi 

You do have two conflicting pieces of logic and you're trying to tailor certain solutions to certain scenarios. If only things were that easy 😂. You need to settle on the following, if you're 32 character is mid-way through a word, you capture this word in the current group or you let it move across to the next group.

 

For example,

Screenshot 2024-10-05 175550.png

 

You can see the different shades of blue in the picture above. This indicates the different grouping every 32 letters, and if it's mid-way through a word it moves it to the next group. In the first example you provided, "of" moves into the next group. In the second example you provided "Park" moves into the current group. 

You can't have it both ways. 

 

The solution I provided in the workflow ensures, if it's mid-way through a word, that it will capture that word in the group it's currently in. 

 

Feel free to use this Regex below, if you want to move the word to the next group, if it's midway through.  

 

 

.{1,32}\b

 

 

 

All the best,

BS

All the best,
BS

LinkedIN

Bulien
pchi
5 - Atom

I dont want break a word mid way, yet fit them into 32 byte chunks.


INPUT String:
Vibrant—A Christian Church Mechanicsburg, Pa.
Expected Result:
Vibrant—A Christian
Church Mechanicsburg, Pa.
rather cutting it down midway.
Vibrant—A Christian Church Mech
anicsburg, Pa.

I will try your solution and will let you know.

thanks

pchi
5 - Atom

when I tried your example,  this is the result I got. Here the first column is 41 chars.

Vibrant—A Christian Church Mechanicsburg|||, Pa|||.

expecting

Vibrant—A Christian Church |Mechanicsburg,pa|||.

lwolfie
11 - Bolide

Not sure if you were able to solve this, but here's a solution.

Labels
Top Solution Authors