Xavier Olive research teaching python blog til cli

How to read a Google Sheets document with pandas

30 August 2022

The most direct way would be to build the URL:

import pandas as pd

url = (

# Take the sheet ID from the URL
df = pd.read_csv(url.format(sheet_id="", sheet_name=""))

If you are behind a proxy and things do not work smoothly, you need to go manual:

import requests
from io import StringIO

s = requests.Session()
s.proxies.update({'https': ""})
c = s.get(url)

txt = StringIO(c.text)

df = pd.read_csv(txt)