Accessing all folders and analyses within a project

I have successfully connected via the python API to my Celonis instance.
I can see that each folder or analysis has an attribute to access which project it belongs to. ie: folder.project

However, if i start from a specific project how do i obtain a list of folders and analyses within it?

I’m essentially aiming to get something like this to begin with:

for p in Project.load_all():
print(p.name)
for f in p.Folder.load_all():
print(’\t\t’+ f.name)
for a in p.f.Analysis.load_all():
print(’\t\t\t’ + a.name)

Hi glove,

welcome to the Celonis Community!

You can do this:

projects = Project.load_all()
for p in projects:
	print(p.name)
	for a in p.folder.get_analyses():
		print('       '+ a.name)
	for f in p.folder.get_subfolders():
		print('       ' + f.name)
		for a in f.get_analyses():
			print('              ' + a.name)

This prints all projects with the analyses that are directly in this project, as well as the direct subfolders and their analyses.

In celonis, Projects, Analyses, DataModels, and subfolders are Folders, which is why you need to reference the corresponding folder of a project to access the children ( p.folder.get_analyses(), p.folder.get_subfolders(), p.folder.get_available_datamodels()).

Hope this helps!
David

3 Likes