You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To work with uploaded files in Google Colab, you have [a lot of options](https://colab.research.google.com/notebooks/io.ipynb). A few recommended options:
69
71
70
72
### Direct upload
71
73
@@ -76,25 +78,45 @@ _Fewer steps, but your file(s) will disappear when your session ends._
76
78
1. In the Google Colab sidebar, click the `Files` icon (A).
77
79
1. Click the upload button (B).
78
80
1. Select your file.
79
-
1.You'll use `read_csv("MY_FILENAME.csv")` in your code.
81
+
1.[Read the file in Python.](#reading-files-in-python)
80
82
81
83
### Google Drive
82
84
83
85
_More steps, but your file(s) are preserved between sessions._
84
86
87
+
Expands on the [instructions to mount Google Drive locally](https://colab.research.google.com/notebooks/io.ipynb#scrollTo=u22w3BFiOveA).
88
+
85
89

86
90
87
91
1. Upload the file(s) somewhere in [Drive](https://drive.google.com/drive/my-drive).
88
92
1. In the Google Colab sidebar, click the `Files` icon (A).
89
93
1. Click the `Mount Drive` icon (B).
90
94
- You may need to run the code it injects to authorize it (C).
91
95
- Think of this as attaching your Drive to your Google Colab instance, as if you were plugging in a USB flash drive.
96
+
1.[Read the file in Python.](#reading-files-in-python)
<iframewidth="560"height="315"src="https://www.youtube-nocookie.com/embed/D5MUsMim_is?start=242"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>
111
+
112
+
### Reading files in Python
113
+
92
114
1. Navigate to the file (D).
93
115
- You may need to click into `content`, then `drive`.
94
116
1. Next to the filename, click the three dots.
95
117
1. Click `Copy path` (E).
96
118
- The value should be something like `/content/drive/My Drive/...`.
97
-
1. Use this path with `read_csv()` (F).
119
+
1. Use this path with [`read_csv()`](https://pandas.pydata.org/docs/user_guide/io.html#csv-text-files) (F).
98
120
99
121
Google Colab cannot access the file on your local machine; in other words, the path shouldn't start with `C:\\` or anything like that. [More info about file paths.](https://www.codecademy.com/resources/docs/general/file-paths)
0 commit comments