Skip to content

Commit 4ef41ab

Browse files
committed
explain InteractiveSheet
1 parent e1c06d9 commit 4ef41ab

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

assignments/open_ended.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ Probably not realistic to make visualizations that are as fancy as these ones ma
6565

6666
## Storing data
6767

68-
To work with uploaded files in Google Colab, you have two options.
68+
<!-- https://github.com/googlecolab/colabtools/issues/5663 -->
69+
70+
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:
6971

7072
### Direct upload
7173

@@ -76,25 +78,45 @@ _Fewer steps, but your file(s) will disappear when your session ends._
7678
1. In the Google Colab sidebar, click the `Files` icon (A).
7779
1. Click the upload button (B).
7880
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)
8082

8183
### Google Drive
8284

8385
_More steps, but your file(s) are preserved between sessions._
8486

87+
Expands on the [instructions to mount Google Drive locally](https://colab.research.google.com/notebooks/io.ipynb#scrollTo=u22w3BFiOveA).
88+
8589
![Steps to get data into Google Colab via Drive](../extras/img/colab_upload_drive.png)
8690

8791
1. Upload the file(s) somewhere in [Drive](https://drive.google.com/drive/my-drive).
8892
1. In the Google Colab sidebar, click the `Files` icon (A).
8993
1. Click the `Mount Drive` icon (B).
9094
- You may need to run the code it injects to authorize it (C).
9195
- 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)
97+
98+
### [InteractiveSheet](https://colab.research.google.com/notebooks/io.ipynb#scrollTo=BC_eQdDHyCji)
99+
100+
You can [import your data into a Google Sheet](https://www.youtube.com/watch?v=C3ic0jqAWJY) and read it directly from Colab.
101+
102+
```python
103+
from google.colab import sheets
104+
105+
sheet_url = ""
106+
sheet = sheets.InteractiveSheet(url=sheet_url, include_column_headers=True)
107+
df = sheet.as_df()
108+
```
109+
110+
<iframe width="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+
92114
1. Navigate to the file (D).
93115
- You may need to click into `content`, then `drive`.
94116
1. Next to the filename, click the three dots.
95117
1. Click `Copy path` (E).
96118
- 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).
98120

99121
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)
100122

0 commit comments

Comments
 (0)