Skip to content

Write and run a Python script in MESA VS Code

Draft: not yet validated

These steps were followed once in the app on 2026-11-13, by the AI assistant that drafted them. No person has yet followed them, so a screen may differ. Tell us what you find.

MESA VS Code is the Visual Studio Code editor in a browser tab, opened on your Data Store. A script you write there is saved in your Data Store as you type.

You will: have a Python script in your Data Store that reads a data file and prints a result.

Time: 10 minutes. You need: to be signed in to the MESA Portal, and readings.csv in a mesa-practice folder in your Data Store, from the practice data or from the Cloud Shell tutorial.

Steps

  1. In the portal, click Applications, and on the MESA VS Code card click Instant Launch. Wait for the editor to open.

    You should see: VS Code, with an Explorer panel on the left that lists the folders of your Data Store home under your username.

  2. In the Explorer, click mesa-practice.

    You should see: the folder open, with readings.csv inside it.

  3. Right-click mesa-practice and choose New File…. Type count_rows.py and press Enter.

    You should see: the new file in the folder, and an empty editor tab named count_rows.py.

  4. Type this into the editor:

    import csv
    
    rows = list(csv.DictReader(open("readings.csv")))
    flagged = [r for r in rows if r["flag"] == "S"]
    print(len(rows), "readings,", len(flagged), "flagged")
    

    You should see: the code coloured as Python. VS Code saves it for you: Auto Save is switched on.

  5. Right-click mesa-practice again and choose Open in Integrated Terminal.

    You should see: a terminal panel under the editor, with a MESA welcome screen and a prompt that ends in mesa-practice $>.

  6. Click in the terminal and run the script:

    python count_rows.py
    

    You should see:

    152 readings, 2 flagged
    

Check it worked

The terminal prints 152 readings, 2 flagged, and count_rows.py is listed in My Files → mesa-practice in the portal's Data Browser.

If it didn't

There is a Chat panel on the right, or notices at the bottom right. A new account sees these the first time, with Restricted Mode in the bottom bar. None of them stops these steps. Close the panel and the notices with their ×.

The command came out garbled. You typed before the terminal had finished starting. Wait for the welcome screen and the prompt, press Ctrl+C, and type it again.

FileNotFoundError: [Errno 2] No such file or directory: 'readings.csv'. The terminal is not in the folder that holds the data. Its prompt shows where it is. Close it, then repeat step 5, making sure you right-click mesa-practice and not the folder above it.

Next

Not yet validated by a person. Drafted with AI assistance on 2026-11-13 and followed once in the app that day.

Machine-readable versions of this page: Markdown twin · raw source on GitHub · llms.txt · llms-full.txt (whole site). See For AI agents.