DEV Community


Write Python Data to CSV in your Web Browser

derricksherrill profile image Derrick Sherrill Updated on ・3 min read


The ability to automate common tasks, like writing CSV, is a huge benefit of using WayScript. The ability to integrate custom code into these automations, such as python and javascript, makes WayScript shine above the others. Let's take a look at how easy it is to create integrations that easily automate your CSV tasks, while giving you unlimited possibilities on how you can customize it for your own needs.


No requirements, but some documentation you may find useful:
Working with Python
Working with CSV

Reading in CSV Files

To start off, you likely already have a CSV document you're looking to process with python. To accomplish this with WayScript we just a CSV module. A module in wayscript can be thought of as a "building block" of a script. We'll use the CSV module to accomplish a CSV action.

csv Action pictures

In this tutorial, I'm just using public data I found online about companies and their funding information. We can upload this CSV file and configure the rest of the settings of the csv module as seen below:

csv Action pictures

Whenever we're reading in any type of spreadsheet styled data, we'll need to import the columns we want to work with. Whenever we import these columns, they will become variables within our script that we can use throughout the workflow.

Processing CSV data with Python

After we've read in the data we want to work with from our CSV document, we can use python programming to do any type of processing we want to do with it. We'll drag in a python module below the csv module:

csv Action pictures

This gives us access to a full python editor in which we can input our own python code. Let's do a simple operation in python and then return the result.

amounts = variables['raised_amount']
new_list = [int(i)*2 for i in amounts]
variables['new_list'] = new_list

The variables dictionary that we're referencing here is how we manage variables in wayscript inside of the python editor. We can access and assign new variables to our script (in wayscript) in this way.

Writing variables back to csv

Once we've done the operations we want to inside of python, we can write that information back to csv. We can do this by using a loop operation.

csv Action pictures

The items that we want to loop over, are each of the list values that we want to write to CSV.

csv Action pictures

With each of these new iterated values, we can write them to CSV using a csv module inside the loop.

csv Action pictures

Questions, Feedback?

As always, if you have any questions please reach out to us on our discord and we would be happy to help. If you want to view this completed script, you can find it here.

Discussion (1)

Editor guide
waylonwalker profile image
Waylon Walker

I have never seen wayscript before. I just checked it out and it looks amazing.