Question

Split text on line items

  • 10 April 2020
  • 5 replies
  • 2709 views

Userlevel 1
Badge

Hi @Danvers 

I’m trying to do something similar. Zapier clearly has split the text into a list of some sort with an index. But on the following step they come in as 1 field. How do I extract say index 2 from that?  


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

5 replies

Userlevel 7
Badge +12

Hi @Matthewzap! I split your reply to new thread as it sounds like you’re trying to do something a little different. 

 

Am I right in thinking that when you look at the output of your Split text Formatter step, you can see what looks like a list of items? Then in the next step of your Zap, there’s only one field that you can add to the Zap, and it is a list of text separated by commas?

 

If that’s the case, then it sounds like the text. that you’re trying to split is starting as line items. That means that when you tell Zapier to split the text using commas, it can’t see any commas, because there’s only line items. 

 

What you need here is two Formatter steps:

  1. Formatter > Utilities > line item to text 
  2. Formatter > Text > Split text

 

The first will take the line items and put them all in one field, separated by commas. When you add the output of this step to the next step, it will look the same (like text with commas in) but it is different. Then the second step will split the text and put each part of it into different fields that you can use. 

 

I hope that makes sense, line items can be a little confusing sometimes!

Userlevel 1
Badge

Thanks @Danvers.

I don’t believe that is the problem. 

When it did it through code using .split() it worked correctly. 

The code step gave me the separate fields I needed as a line item. 

When I did it through Split Text, the test looks like it worked, but the next step (Update Airtable) has them all in 1 field.

 

When it did it through code using .split() it worked correctly. 

The code step gave me the separate fields I needed as a line item. 

When I did it through Split Text, the test looks like it worked, but the next step (Update Airtable) has them all in 1 field.

 

Hi @Matthewzap 

Were you able to find a no-code solution for splitting the text?  I’m having the same issue trying to break the output of a digest so that I can insert it into an email.

I’m not familiar enough with using python or the code block to use the .split() function. 

Any pointers on what you settled on would be helpful.

Userlevel 1
Badge

Sorry, no I couldn’t. It just wouldn’t go through. 

I can help you with .split if you want. It is a basic code.

The main gist of it is you’d define your inputs.

temp = input.split() //where you define a variable and split the fields into it 

output = {“Field Name 1”:temp[0],”Field Name 2”:meta[1], "Field Name 3":meta[2]} //which defines the fields and sends them to the next step.

 

In the next step you’ll choose the Code zap, and you’ll see a list of the field names as you defined them, so Field Name 1, Field Name 2, Field Name 3.

 

Hope that helps.

Thank you - I’ll abandon my efforts to make Zapier do what I want with the Formatter! 

I’ll play around with the starter code and see where I get to.

Thank you for the help, it’s much appreciated