Created
June 11, 2014 04:20
-
-
Save restrepo/e8b8ba39079b0631284e to your computer and use it in GitHub Desktop.
GoogleSpreadSheet2Pandas.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_google_cvs(gss_url="http://spreadsheets.google.com",\ | |
gss_format="csv",\ | |
gss_key="0AuLa_xuSIEvxdERYSGVQWDBTX1NCN19QMXVpb0lhWXc",\ | |
gss_sheet=0,\ | |
gss_query="select B,D,E,F,I where (H contains 'GFIF') order by D desc",\ | |
gss_keep_default_na=False | |
): | |
import urllib | |
import pandas as pd | |
""" | |
read a google spreadsheet in cvs format and return a pandas DataFrame object. | |
.... | |
gss_keep_default_na: (False) Blank values are filled with NaN | |
""" | |
issn_url="%s/tq?tqx=out:%s&tq=%s&key=%s&gid=%s" %(gss_url,\ | |
gss_format,\ | |
gss_query,\ | |
gss_key,\ | |
str(gss_sheet)) | |
gfile=urllib.urlopen(issn_url) | |
return pd.read_csv(gfile,keep_default_na=gss_keep_default_na) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment