How to upload data file on Google Colab
Using Google Colab for Python programming is so useful because the code runs on Google server, so it does not require high computation on your computer and it also enables GPU for complex programming such as deep learning. You don't need to install Python and Jupyter notebook. You can just go to Google Colab and type codes there and then you can directly run your code. It also has the most common packages already installed so you don't need to install each package every time. There are tons of advantages for using Google Colab. Today, I will show you how to upload your data file on Google Colab for data analysis.
1. Upload data files to runtime session
You can upload your files to run time session. This way, if you lose the runtime session connection, you should upload your file again. What you need to do is once you run your code, the runtime will be on and then on the left side you will see a folder icon and click it. Then, you need to find a folder named 'content'. If you don't see one, you would need to click '..' and then you will be able to find the folder. You need to right-click on 'content' folder and then click 'upload' and then select data files you want to upload. And that's it. The content folder will act like your local folder, so you will be able to load your data on Google Colab.
2. Upload data files to your Google drive and connect both Google Colab and Google Drive
You can upload your data files in a different way. If you want to run your code on Google Colab repeatedly, you might better use this method than number 1. First, you need to go to your Google Drive and you will find 'Colab Notebooks' folder. If you ever ran any code on Google Colab you would see this folder, if you didn't then run any code on Google Colab first and then find again. You may upload your file in this folder or if you want to seperate a folder for data files you can make a new folder inside Colab Notebooks folder. After that, you go to Google Colab code and then use the code below to connect your google drive with your colab code. And there will be pop-up showing to ask you if you really want to connect the google drive and you can check yes. Now you can load your data that is in your google drive. Please refer to the code below.
With both methods, you can also download files. With the first method, you would find your downloaded file in the content folder and with the second method, you would find your downloaded file in your google drive folder. I hope this helped you figure out how to upload your data on Google Colab for data analysis.
Comments
Post a Comment