0

I have the following directory structure

enter image description here

enter image description here

As you can see in the pics, there are a lot of .0 files in different directories. This directory structure exists for 36 folders(Human_C1 to C36) and each Human_C[num] folder has a 1_image_contours folder which has a contours folder with all related .0 files.

These .0 files contain some co-ordinates(x,y). I wish to loop through all these files, take the data in them and put it in an excel sheet(I am using pandas for this).

The problem is, how I loop through only these set of files and none else? (there can be .0 files in contour_image folders also)

Thanks in advance

1 Answer 1

3

Since your structure is not recursive I would recommend this:

import glob
zero_files_list = glob.glob("spinux/generated/Human_C*/*/contours/*.0")
for f in zero_files_list:
    print("do something with "+f)

Run it from the parent directory of spinux or you'll have no match!

It will expand the pattern for the fixed directory tree above, just as if you used ls or echo in a linux shell.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.