This topic was automatically generated from Slack. You can find the original thread here.
Hi , I am trying to run a simple 3 step workflow in which:
A google file trigger when a file is uploded or changed
A python script to read and modify the file
A google sheet update rows function based on the output from step 2.
The isse is that I get a Pipedream interal error on the return from step 2. I made sure that the output is a nested array so the google sheet update can parse it, any ideas?
To create the workflow you described, you can follow these steps: 1. Google File Trigger: Search for the Google Drive trigger in the Pipedream UI that activates when a file is uploaded or changed. You’ll need to connect your Google account and configure the trigger to watch for changes in a specific folder or file. 2. Python Script: Add a Python code step to read and modify the file. You’ll use the Python integration to execute your script. Make sure to pass the file data from the Google Drive trigger to this step. 3. Google Sheets Update Rows: Finally, search for the Google Sheets action in the Pipedream UI that updates rows based on the output from your Python script. Connect your Google account and map the output from the Python step to the appropriate fields in the Google Sheets action. Here’s a high-level example of how the Python code step might look: def handler(pd: "pipedream"): # Access the file from the Google Drive trigger file_data = pd.steps["trigger"]["output"] # Your Python code to read and modify the file # ... # Return the modified data for use in the next step return {"modified_data": modified_file_content} And for the Google Sheets update rows function, you would configure the action to use the modified_data from the Python step. Please note that you’ll need to handle the specifics of reading the file and updating Google Sheets rows according to your exact requirements, which might involve additional API calls or processing logic. If you need further assistance with the Python script or the Google Sheets action, please provide more details on how you want to modify the file and update the rows, and I can help with more specific code examples.
def handler(pd: "pipedream"):
# Reference data from previous steps
print(pd.steps["trigger"]["context"]["id"])
# Return data for use in future steps
return {"foo": {"test": True}}
def handler(pd: “pipedream”): # Reference data from previous steps
info_nueva = pd.steps[“trigger”][“event”][“file”][“id”]
_#Transform into a pandas df, then back to a dict_
final_data = transform_df(info_nueva).to_dict("split")
_#Only keep necesary data_
final_dictionary = [final_data['columns']] + final_data["data"]
_# Return data for use in future steps_
**return** final_dictionary
the return values is a nested array like this [[“Foo”,1,2],[“Bar”,3,4]]
Ah wait, so it’s not returning anything, it was just an example of what it should return?