Lastly, the reason your code fails is probably because you're either trying to access local files (like your Mac's 'Downloads' folder) when you're working in an online Notebook (like Kaggle, which hosts your environment for you, online and away from your Mac), or you moved or deleted something in that path. the os module in Python) you can likely use the notebook filename. The takeaway is that the notebook has a file name, and as long as your language supports pathname manipulations (e.g. From there, use the os module and your path to navigate.įor example, if your train.csv is in a folder called 'Datasets', and the notebook is sitting right next to that folder, you could get the data like this: train_csv = os.path.join(os.path.dirname(notebook_path), "Datasets/train.csv") In other words, just use the os module, and get the absolute path of your notebook (it's a file, too!). Notebook_path = os.path.abspath("Notebook.ipynb") You are currently working in that notebook, and want to access other folders and files around it. Let's say you have a notebook with a file name, call it Notebook.ipynb.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |