How to transfer a csv file from notebook folder to a datastore

Question:

I want to transfer a generated csv file test_df.csv from my Azure ML notebook folder which has a path /Users/Ankit19.Gupta/test_df.csv to a datastore which has a web path https://abc.blob.core.windows.net/azureml/LocalUpload/f3db18b6. I have written the python code as

from azureml.core import Workspace
ws = Workspace.from_config()
datastore = ws.get_default_datastore()
    
datastore.upload_files('/Users/Ankit19.Gupta/test_df.csv',
                  target_path='https://abc.blob.core.windows.net/azureml/LocalUpload/f3db18b6',
                  overwrite=True)

But it is showing the following error message:

UserErrorException: UserErrorException:
    Message: '/' does not point to a file. Please upload the file to cloud first if running in a cloud notebook.
    InnerException None
    ErrorResponse 
{
    "error": {
        "code": "UserError",
        "message": "'/' does not point to a file. Please upload the file to cloud first if running in a cloud notebook."
    }
}

I have tried this but it is not working for me. Can anyone please help me to resolve this issue. Any help would be appreciated.

Asked By: ankit

||

Answers:

The way the path was mentioned is not accurate. The datastore path will be different manner.
Replace the below code for the small change in the calling path.

enter image description here

from azureml.core import Workspace
ws = Workspace.from_config()
datastore = ws.get_default_datastore()
    
datastore.upload_files('./Users/foldername/filename.csv',
                  target_path=’your targetfolder',
                  overwrite=True)

We need to call all the parent folders before the folder. “./” is the way we can call the dataset from datastore.

Answered By: TadepalliSairam