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
Answers
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,225 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.
-
Thanks Alex for your quick answer,
We have dataset hierarchy as follows:
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
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,225 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.