Can't access subfolder's in a processing project

Hello,

I’m new to processing with Python and I want to access subfolders in my data folder with my processing project. If I loop through the folders with os.listdir(), only see the main.pyde. I’ve already tried dataPath and dataFile but without success.

My current folder structure is:
main.pyde
sketch.properties
data

  • Subfolder1
  • Subfolder2
  • Subfolder3

Kind Regards,

Corné

1 Like

Hi,

Welcome to the forum! :wink:

I have this folder structure :

.
├── data
│   ├── folder_1
│   └── folder_2
├── sketch.properties
└── test_python.pyde

I tested this code :

import os

def setup():
    print(os.listdir("./data"))
    
def draw():
    pass

And it works :

['folder_1', 'folder_2']

But be sure to save your file before running, it was not updating in my case so at the beginning I thought it was not working properly.

And also your error might be that you omitted to put the data folder inside the path, I know that in Processing Java the relative path is in the data folder but maybe in python it’s not the case…

2 Likes
2 Likes