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
Let's take a few moments to explore the \"Files\" menu in the Google Colab left sidebar.
4
+
5
+
We see there are some example files in the \"sample_data\" directory.
6
+
7
+
{height=350 fig-align="center"}
8
+
9
+
## Downloading Files
10
+
11
+
Observe, it is possible to download files like these from the Colab filesystem to your local machine, by right-clicking on them.
12
+
13
+
14
+
{height=350 fig-align="center"}
15
+
16
+
## Uploading Files
17
+
18
+
And it is possible to upload files from your local machine to the Colab filesystem as well, using the "Files > Upload to session storage" menu option (i.e. the button with the file upload icon).
19
+
20
+
{height=350 fig-align="center"}
21
+
22
+
## Accessing and Manipulating Files
23
+
24
+
Once we have the files in the Colab filesystem, we can write Python code to access and manipulate them.
25
+
26
+
+ One way of interacting with the filesystem in Python is by using the capabilities of [the `os` module](../../python-modules/os.ipynb).
27
+
28
+
+ For reading and writing text (\".txt\") files, we can leverage the `open` function (see [Text File Operations](../../python-lang/file-operations.qmd)).
29
+
30
+
+ For reading and writing tabular data (\".csv\") files, we can leverage the `pandas` package (see [Getting Started with Pandas](https://prof-rossetti.github.io/applied-data-science-python-book/notes/pandas/obtaining-dataframes.html)).
31
+
32
+
Some of these examples might seem a bit complicated at the moment for beginners. For now, the main take-away is understanding there are ways for us to write Python code to interact with the surrounding environment, specifically accessing and manipulating the filesystem.
0 commit comments