black and silver laptop computer on table

Editing Scripts

First off, you may need to edit your scripts and the best way to do that is with this free app: Notepad++

You can download it from HERE

You can open up .py (python files) and .js (Node.js) files with this editor very easily. But don’t worry – we’ll show you how later on.

Getting organized

Next, you’ll want to set up a folder structure for saving your scripts. I recommend every different script has its own folder. Let’s say your first script is called “Script1.py” and it’s inside the SCRIPTS folder in your Documents folder.

So the path to your script is C:\Users\Yourname\Documents\SCRIPTS\Script1\Script1.py

When we want to run the script, we open up the CMD window and first set it so that it’s looking for scripts in the right folder by using the cd command, like this

C:\Users\Yourname> cd C:\Users\Yourname\Documents\SCRIPTS\Script1

It’s important you always ensure the CMD window is looking in the right folder, so use the cd command at the start.

The quick way to find the path to the folder is to open up Windows File Explorer and navigate to the folder you want. Then copy the path by right clicking and “copy address as text”. You can paste that into your CMD window

To run the script is easy: just type the name of the script like this, and hit enter:

C:\Users\Yourname> cd C:\Users\Yourname\Documents\SCRIPTS\Script1
C:\Users\Yourname\Documents\SCRIPTS\Script1>Script1.py

And that’s how you run a simple script.

Calling up .csv files

You’ll often want the script to call up data that has been saved in a .csv file (say “input.csv”), and it may end up saving the output in another .csv file (say “output.csv”). You can save those files in the same folder as the script, or, to keep organised, set up another folder with your data in. You may have to tweak your script so that it knows where to find and save those files.

Troubleshooting

It’s not unusual for scripts to go wrong – usually for very simple reasons. I find the best way to figure out what the problem is, is to use ChatGPT. (If you don’t have an account, set one up – it’s free and a fantastic resource to help you troubleshoot, modify and build scripts.)

The approach I usually adopt is this:
a) “Please explain how this script works” – then paste in the code.
b) “Please identify any syntax or other errors in this script” – ChatGPT is usually pretty good at finding problems.
c) Alternatively – if you have run a script which returned an error, paste in the error message and ask ChatGPT to comment on, and fix the problem.