Reputation: 21
I am trying to upload a Python script I wrote for Jupyter Notebook to Microsoft Azure Notebooks, but it is not working correctly.
The Microsoft Azure project has a folder with XLSX files that I am trying to read, and the Python script. When I run the Python script on Jupyter Notebook it doesn't access the folder I previously uploaded to the project.
path =r'/Users/chorozco/Documents/Dr.Irwin/6 Column Data Acquisition Converted'
filenames = glob.glob(path + "/*.xlsx")
path = os.getcwd()
files = os.listdir(path)
files
I am expecting the list of the files inside "6 Column Data Acquisition Converted", but instead I get a list of the files inside my Microsoft Azure Project:
Expectation: Script run from Anaconda in my computer
Reality: Script run from Microsoft Azure Notebooks
Upvotes: 1
Views: 2221
Reputation: 24138
Just according to your code path =r'/Users/chorozco/Documents/Dr.Irwin/6 Column Data Acquisition Converted'
, I think you are working on MacOS, not Linux. However, Microsoft Azure Notebooks is based on Linux for running. So the difference of code os.listdir(path)
between Azure Notebook and your local Anaconda is caused by the different implementation of Python for this feature os.listdir
on different OS like MacOS other than Linux and Windows, the result without the files recursively listed in the directories.
Here is my steps as reference.
I created a new project named Test for listing xlsx files in a path of Azure Notebook Project
in my account of Microsoft Azure Notebooks, and to create a new folder 6 Column Data Acquisition Converted
as the figures below.
Fig 1.
Fig 2.
I created some xlsx files on my local Windows for uploading, then move to the folder I created in Azure Notebook project previously to do the upload operation as the figures below.
Fig 3.
Fig 4.
Fig 5.
Fig 6.
I created a notebook in Python 3.6 to run the same code with yours.
Fig 7.
Fig 8.
I found the result is as same as the code on my local Linux and Windows, but other than your result on MacOS.
Fig 9. The almost same code run in Python 3.6 of Azure Notebook
Fig 10. The almost same code run in Python 2.7 of Azure Notebook
Fig 11. The result of os.listdir
on Windows
Fig 12. The result of os.listdir
on Linux
So I think the issue was caused by MacPython, please check it again. Hope it helps.
Upvotes: 1