We're excited to announce that we're launching the second installment of Dataiku Product Days Register Now

managed folder issue

Swapnali
Level 3
managed folder issue

Hi Team,

I am following https://www.kaggle.com/mcahitgamsz/product-image-for-quality-inspection-scv-acc-99

i am stuck with cell no. 4 , as i have 2 folders named "Train" and "Test"

In "Train" there are 2 more folders named "def_front" and "OK_front".

so i am using below code as:

import dataiku
files = ['def_front', 'ok_front']
adress = dataiku.Folder("b7SXqJ56")
data_train = {}
for f in files:
data_train[f]=[]
for col in files:
os.chdir(adress.format(col))
for i in os.listdir(os.getcwd()):
if i.endswith('.jpeg'):
data_train[col].append(i)

 

and i am getting error like:

<ipython-input-6-db47d71d890e> in <module>
7 data_train[f]=[]
8 for col in files:
----> 9 os.chdir(adress.format(col))
10 for i in os.listdir(os.getcwd()):
11 if i.endswith('.jpeg'):

AttributeError: 'folder' object has no attribute 'format'

 

kindly help to resolve this issue

 

0 Kudos
3 Replies
AlexT
Dataiker
Dataiker

The error "AttributeError: 'folder' object has no attribute 'format'"  is due "adress" is an object that does have the attribute format,.

You would need to use:

adress = dataiku.Folder("local_models").get_path()

Instead to get the path actual path. Let me know if this is what you were trying to do. 

Screenshot 2021-07-28 at 17.40.41.png

0 Kudos
Swapnali
Level 3
Author

Thanks Alex for your quick answer,

We have dataset hierarchy as follows:

dataikuerro.PNG

Train and Test are 2 folders and inside we have 2 more folders in each named Def_front & Ok_front

and in def_front and ok_front , there are 2-3k .jpng files.

we want to access them how can we do that with above code

 

0 Kudos
AlexT
Dataiker
Dataiker

Hi,

As far as I saw the code sample you shared will will list the file in the root directory and the subdirectories but not contents of the subdirectories.

You can have a look at sample provided here which will list all files and you can filter by the subdirectories and .jpeg as needed. 

 https://community.dataiku.com/t5/Using-Dataiku-DSS/Listing-and-Reading-all-the-files-in-a-Managed-Fo... 

0 Kudos
A banner prompting to get Dataiku DSS