Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Looping through directories in Python using f-string

I am trying to access 2 different directories in ADLS using for loop & f-string but facing issues in doing so

# Primary storage info
 account_name = "accountnamehere"  # fill in your primary account name
 container_name = "logscontainer"  # fill in your container name
 subscription_id = "subscriptionname"
 resource_group = "My-Resource-ML" # fill in your resource gropup for ADLS account
 workspace_name = "My-Workspace-ML" # fill in your la workspace name

 datasets=[test1,test2]
 for df in datasets :
    input_path = f"datasets"
    print(input_path)

I get the following error

----> 8 datasets=[{test1},{test2}]
      9 for df in datasets :
     10     input_path = f"datasets"

NameError: name ‘test1’ is not defined

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Can someone help ?

>Solution :

How about the following:

datasets = ['test1', 'test2']
for df in datasets:
    input_path = f"{df}/subdirectory"

?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading