I have written some code in Jupyter Notebook, that runs locally on my windows PC. When it imports folders i use "\".
However i have just moved all the folders to my google drive, & opened it with Colab. Now the in the directory path the folders are separated with "/", thus giving error.
How do I import foders regardless of whether i am running it locally on my PC, or online.
# added this bit so i can import and run the code in colab
import os
from google.colab import drive
drive.mount('/content/drive')
os.chdir('/content/drive/My Drive/Dashboarding_Project/Folder_with_all_IV_curves/Python_IV')
#From the JUPYTER NOTEBOOK file
import pandas as pd
import os
import re
#these variables contain hte excell file with hte mask info & the file with the batch info
meta_mask_name = "MASK-1_2020-03-01.xlsx"
meta_batch_name = "BATCH-1-2_2020-8-20--EXAMPLE.xlsx"
#This is the main directory of the foler structure
path_parent = os.path.dirname(os.getcwd())
print("Main folder: ", path_parent)
print("Folders: ", os.listdir(path_parent))
print (os.listdir(path_parent +r"\MASK_META")) # this gives error now that i am using it online.
OUT:
FileNotFoundError: [Errno 2] No such file or directory: '/content/drive/My Drive/Dashboarding_Project/Folder_with_all_IV_curves\\MASK_META'
CONTEXT
I am using both Colab and Jupiter becuase:
- Colab is easy to share, dont have to download anything and can access it anywhere.
- Jupyter i can use and Deploy locally PANEL, and Colab wont allow me to view it locally.
My end objective is to have:
- A dashboard (Panel or something else) fully online
- Dashboard runs on a server not my PC (Like Heroku)
- I can send the link to someone and they can view it.
Maybe someone has a solution to this problem that avoids the main quesiton.