First off, welcome to the Pipedream community. Happy to have you!
Congrats! You’ve figured out how to consume Step Exports from other steps, the other half to learn is how to pass data from a code step to Step Exports.
You can use the built in export function described here in the Python docs: Python
So you could do something like:
from pipedream.script_helpers import (steps, export)
# text processing here
export('txt', txt)
Then you can consume this step’s exports just like the initial Google Sheets trigger.
I’m sorry I thought you had already connected those dots. The referencing of the step data and your text processing should happen in the same Python step:
from pipedream.script_helpers import (steps, export)
import re
txt = steps[“trigger”][“event”][“newRow”]
# You're now ready to perform some actions like regex testinsg, etc.
# But remember that Python strings are immutable!
export('txt', txt)
This video explains how to use Step Exports with pre-built actions:
And this video shows how to use Step Exports with Node.js steps:
Thanks I’ll take a look and try this. As I was having success just running the Python step when inputting the data e.g. txt = “the meatballs are great” but when I try to input newRow as the data that’s when it is having issues. so hopefully your suggestion works
from pipedream.script_helpers import (steps, export)
import re
txt = steps["trigger"]["event"]["newRow"]
export('txt', txt)
a = re.findall(r”\b(pizza|pissa)\b”, str(txt), re.IGNORECASE)
if a:
a1 = re.findall(r”\b(pizza|pissa)(?:\W+\w+){0,3}?\W+(small|medium|large)\b|\b(small|medium|large)(?:\W+\w+){0,3}?\W+(pizza|pissa)\b", str(txt), re.IGNORECASE)
if a1:
print(“pizza order“)
if not a1:
print(“need size”)
Thanks for sharing your code - you can use export as many times as you wish in a code step.
I suggest you export a variable called pizza_order that contains a1:
from pipedream.script_helpers import (steps, export)
import re
txt = steps["trigger"]["event"]["newRow"]
export('txt', txt)
a = re.findall(r”\b(pizza|pissa)\b”, str(txt), re.IGNORECASE)
if a:
a1 = re.findall(r”\b(pizza|pissa)(?:\W+\w+){0,3}?\W+(small|medium|large)\b|\b(small|medium|large)(?:\W+\w+){0,3}?\W+(pizza|pissa)\b", str(txt), re.IGNORECASE)
if a1:
print(“pizza order“)
if not a1:
print(“need size”)
# Export the result of the regex operation as "pizza_order" for the next steps in your workflow to use.
export("pizza_order", a1)
But pizza_order can be empty or undefined, so I suggest adding a Filter action between your Python Step and the Google Sheets updating step.
Thank you for this! I did test this method and while it works great, I would have to change my Python code to include the export for print as you have (not sure I want to as it would mean changing possibly thousands of lines)
If you need assistance with specific conversions or implementations of workflows I recommend you post to our job board here: Hire an expert - Pipedream
An expert will get in touch with you and can help you implement the changes you need.