Skip to main content

Hello all,

Thanks in advance for the help!

I have a Gmail → Formatter → Sheets zap set up to: Extract (varying quantity of) multiple 12-digit numbers from the e-mail body, then updating the sheets with multiple rows. While i was able to successfully extract the 12-digit strings as multiple items, it does not return as line items - this is an issue because of the varying quantity of 12-digit strings that the e-mail body might contain.

I recently was successful in extracting 5 sets of numbers, and individually inputting the 5 sets of numbers as multiple rows on the sheet. But it limits me to 5 sets of numbers for the zap, while i may potentially have (varying) 1 to 40 sets of 12-digit numbers on a single e-mail body; this method also creates 5 similar rows on the sheet if the e-mail body has only 1 set 12-digit strings.

I’m not sure how i could make the initial (transform) extraction return as line items.

 

Thought this might be important: The formatter returns these. The _end, _matched & _start seemingly seemed to be able to return as line items - only need to input a single output into the sheets data, and it will return as 5 separate lines.

 


Hi there @consignscc

Ah yes, I did some testing just now and can see what you mean about the output from the Formatter action. Hmm, in order to have a varying number of 12 digit numbers extracted I think your best bet may be to handle it in a Code by Zapier action instead of using Formatter. 

I did some playing around and was able to get a list of all 12 digit numbers, extracted from some text using the following setup:
fda1973aa34ace7ba3dee52eff19aac2.png

This output them into a field called Numbers:
5f6fec5107e29740e47a92ab345f5f6c.png

Here’s the code that you can copy and paste into the Code action if you’d like to give this a try:

import re
email = input_datan'emailText']
match = re.findall(r'\b\d{12}\b', email)

if match:
return {'Numbers': match}]

From there, in a Create Multiple Spreadsheet Rows action you can select the Numbers field that’s output by the Code action and that will allow it create multiple Spreadsheet rows, for each of the different numbers that were extracted.

If helpful you can learn more about how to use Python Code actions here:


Hope that helps. If I’ve misunderstood the end goal here or you run into any issues on that just let me know!