DEV Community

loading...
Cover image for Integrate Google Sheets seamlessly to Other Services | WayScript Tutorial
WayScript

Integrate Google Sheets seamlessly to Other Services | WayScript Tutorial

Derrick Sherrill
Software developer who sometimes makes videos
・2 min read

Introduction

In previous articles, we’ve discussed how to use Python and Google Sheets together to create a variety of programs. However, WayScript has just introduced a new spreadsheet editor that allows users to view and edit any Google Sheet in full screen mode. This is much easier to use and navigate than before, so in this article we’ll explore the feature and use it in a program that passes the information to Python. Keep reading to learn more!

Building our Script

This simple example uses the Google Sheets and Python modules. Beginning with Google Sheets, in the toolbar to the left there are options to read or write a file. Once you’ve chosen one of these options (we’ll read a file for this script), click on the “Setup” button below the drop-down menu. This brings up the full screen editor. This is much more user-friendly than before, where the data was shown inside the toolbar. Choose which file and sheet to read from the toolbar, and then import the columns at the top. These steps are similar to the previous format and create stored WayScript variables.

Clicking “Exit Read Setup” returns the user to the tree building view. The next step in this script is to add the Python module so that we can write code to perform a variety of functions. Clicking on “Enter Edit Code” in the toolbar brings up the code editor screen. There are several different bits of code that can be used here, but we’ll just use the “numpy” package to perform a few simple calculations on our data. The specific code used to do this is shown below.

Python code for the calculations:

import numpy as np 
one = [float(i) for i in variables[‘values_one’]]
two = [float(i) for i in variables[‘values_two’]]
result = np.array(one) / np.array(two) 
variables[‘result’] = result.tolist()  

The result of that code is now stored as a variable. From here, you could choose to send it as an e-mail, create a hosted dashboard, and more. You can see how to build some of those scripts in other articles, but for now we simply wanted to run through the application of the new spreadsheet editor. We’re always looking to improve the WayScript platform, and these new features are just a few ways we’re doing that.

Conclusion

Questions about this script or anything else? Join our discord. We're always around to help. If you want to work the full script template, just find it here.

Discussion (0)