Load CSV in Google Colab
Upload, Drive
or GitHub URL.
Three ways to read a CSV in Google Colab — files.upload() for local files, Google Drive mount for persistent data, or a raw GitHub URL for public repos. Enter your filename and paths — the code updates live, ready to paste into a cell.
Which method should you use?
Each method suits a different workflow — here is the decision guide.
| Method | Persists after session? | Shareable notebook? | Best for |
|---|---|---|---|
| files.upload() | ✗ Deleted on session end | ✗ Others must re-upload | One-off local files, quick exploration |
| Google Drive | ✓ Survives restarts | ✗ Others need their own Drive | Recurring use, large files, private data |
| GitHub URL | ✓ Always available | ✓ Anyone can run the notebook | Public data, shared notebooks, demos |
How to find the GitHub raw URL
Three clicks from any CSV file in a public GitHub repo.
Open the CSV on GitHub
Navigate to your repository on github.com and click the CSV file to open it. GitHub shows a preview of the data inside the browser.
Click Raw
At the top right of the file preview, click the Raw button. The browser navigates to the plain-text version of the file — the URL changes to raw.githubusercontent.com.
Copy the URL into Colab
Copy the raw URL from the browser address bar and paste it into the GitHub URL input above. The code snippet updates automatically and is ready to run in Colab.
Common Colab + CSV workflows
Data science exploration
Colab is the standard environment for quick data exploration. Upload a CSV with files.upload(), run describe() and visualise distributions with matplotlib — no local Python setup required.
Teaching and sharing notebooks
Notebooks shared as Google Colab links work for anyone with a Google account. Hosting the CSV on GitHub and using the raw URL means students can run the notebook without uploading any files.
Machine learning pipelines
Training data stored in Google Drive can be read directly into a Colab GPU runtime — no download to local machine, no re-upload. The Drive mount makes large CSVs available without copying files between environments.
Reporting and dashboards
Scheduled CSV exports from business tools (CRMs, analytics platforms) can be saved to Google Drive and read into Colab notebooks for automated weekly or monthly reporting with pandas and plotly.
Related CSV tools
Code that runs first time,
personalised to your paths. No guessing.
The three code snippets above are generated live from your inputs — your filename, your Drive folder, your GitHub URL. No placeholder strings to find and replace. Paste the code directly into a Colab cell and run it.
The comparison table shows the real trade-offs: files.upload() is fast but temporary, Drive mount persists across sessions, GitHub URL makes your notebook shareable for anyone to run. Choose based on your workflow, not based on which snippet you found first in a Stack Overflow answer.
Three methods covered
Live personaliser
Decision table
Free, no conditions
How do I load a CSV into Google Colab?
files.upload() — a file picker appears in the cell output, select your CSV, then pd.read_csv(filename). 2) Mount Google Drive and read from /content/drive/MyDrive/. 3) Paste a raw GitHub URL directly into pd.read_csv(url) for public repos.Does Google Colab save uploaded files permanently?
files.upload() are stored in /content/ and deleted when the session ends or the runtime is recycled (typically after 12 hours of inactivity). For persistent data, use Google Drive mount — Drive files survive session restarts.How do I read a CSV from Google Drive in Colab?
from google.colab import drive; drive.mount('/content/drive'). A Google auth link appears — authorise access. Then read your file: df = pd.read_csv('/content/drive/MyDrive/your_file.csv'). The mount persists as long as the runtime is active.How do I share a Colab notebook that reads a CSV?
pd.read_csv('https://raw.githubusercontent.com/...'). Anyone with the Colab link can run the notebook without uploading any files. This is the standard approach for teaching notebooks and public demos.Why is my CSV showing encoding errors in Colab?
pd.read_csv('file.csv', encoding='latin-1') or encoding='cp1252'. If the file has a UTF-8 BOM: encoding='utf-8-sig'.