Google Sheets Reader
Insert the link to your Google Sheet
URL
import pandas as pd
import re
# This function will convert the url to a download link
def convert_gsheets_url(u):
try:
worksheet_id = u.split('#gid=')[1]
except:
# Couldn't get worksheet id. Ignore it
worksheet_id = None
u = re.findall('https://docs.google.com/spreadsheets/d/.*?/',u)[0]
u += 'export'
u += '?format=csv'
if worksheet_id:
u += '&gid={}'.format(worksheet_id)
return u
sample_url = 'https://docs.google.com/spreadsheets/d/1ih4V4CumuIl5ZynobsazNzGiaPrE2V2Dpt13FI22XNU/edit'
try:
url = convert_gsheets_url(URL)
df = pd.read_csv(url)
print('Read successfully')
except:
print(f"Could not read any data from the URL you provided.\nReading from {sample_url} instead.")
url = convert_gsheets_url(sample_url)
df = pd.read_csv(url)
Here is a sample of the data we were able to find: