<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://info.gersteinlab.org/index.php?action=history&amp;feed=atom&amp;title=Grab_GoogleSpreadsheet_with_a_Python</id>
	<title>Grab GoogleSpreadsheet with a Python - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://info.gersteinlab.org/index.php?action=history&amp;feed=atom&amp;title=Grab_GoogleSpreadsheet_with_a_Python"/>
	<link rel="alternate" type="text/html" href="https://info.gersteinlab.org/index.php?title=Grab_GoogleSpreadsheet_with_a_Python&amp;action=history"/>
	<updated>2026-05-14T09:16:24Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.6</generator>
	<entry>
		<id>https://info.gersteinlab.org/index.php?title=Grab_GoogleSpreadsheet_with_a_Python&amp;diff=1656&amp;oldid=prev</id>
		<title>Public: /* Code */</title>
		<link rel="alternate" type="text/html" href="https://info.gersteinlab.org/index.php?title=Grab_GoogleSpreadsheet_with_a_Python&amp;diff=1656&amp;oldid=prev"/>
		<updated>2011-09-16T10:49:01Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:49, 16 September 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l27&quot;&gt;Line 27:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 27:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&amp;#039;&amp;#039;&amp;#039; An iterable google spreadsheet object.  Each row is a dictionary with an entry for each field, keyed by the header.  GData libraries from Google must be installed.&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&amp;#039;&amp;#039;&amp;#039; An iterable google spreadsheet object.  Each row is a dictionary with an entry for each field, keyed by the header.  GData libraries from Google must be installed.&amp;#039;&amp;#039;&amp;#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	def __init__(self, spreadsheet_id, worksheet_id, user=&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;programmer@gersteinlab.org&lt;/del&gt;&#039;, password=&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;alpaca&lt;/del&gt;&#039;, source=&#039;&#039;):&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;	def __init__(self, spreadsheet_id, worksheet_id, user=&#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;**********&lt;/ins&gt;&#039;, password=&#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;************&lt;/ins&gt;&#039;, source=&#039;&#039;):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		gd_client = gdata.spreadsheet.service.SpreadsheetsService()&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		gd_client = gdata.spreadsheet.service.SpreadsheetsService()&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		gd_client.email = user&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;		gd_client.email = user&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Public</name></author>
	</entry>
	<entry>
		<id>https://info.gersteinlab.org/index.php?title=Grab_GoogleSpreadsheet_with_a_Python&amp;diff=1655&amp;oldid=prev</id>
		<title>Public: Created page with &#039;==Example Usage== &lt;code&gt;&lt;pre&gt; from GoogleSpreadsheet import GoogleSpreadsheet  spreadsheet_id = &quot;o04764524430027910313.8987538912905796708&quot; # Unique Spreadsheet ID worksheet_id =…&#039;</title>
		<link rel="alternate" type="text/html" href="https://info.gersteinlab.org/index.php?title=Grab_GoogleSpreadsheet_with_a_Python&amp;diff=1655&amp;oldid=prev"/>
		<updated>2011-09-16T10:47:41Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;==Example Usage== &amp;lt;code&amp;gt;&amp;lt;pre&amp;gt; from GoogleSpreadsheet import GoogleSpreadsheet  spreadsheet_id = &amp;quot;o04764524430027910313.8987538912905796708&amp;quot; # Unique Spreadsheet ID worksheet_id =…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Example Usage==&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
from GoogleSpreadsheet import GoogleSpreadsheet&lt;br /&gt;
&lt;br /&gt;
spreadsheet_id = &amp;quot;o04764524430027910313.8987538912905796708&amp;quot; # Unique Spreadsheet ID&lt;br /&gt;
worksheet_id = &amp;quot;od6&amp;quot;&lt;br /&gt;
&lt;br /&gt;
spreadsheet = GoogleSpreadsheet(spreadsheet_id, worksheet_id)&lt;br /&gt;
for row in spreadsheet:&lt;br /&gt;
  print row[&amp;quot;lastname&amp;quot;]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
try:&lt;br /&gt;
  from xml.etree import ElementTree&lt;br /&gt;
except ImportError:&lt;br /&gt;
  from elementtree import ElementTree&lt;br /&gt;
import gdata.spreadsheet.service&lt;br /&gt;
import gdata.service&lt;br /&gt;
import atom.service&lt;br /&gt;
import gdata.spreadsheet&lt;br /&gt;
import atom&lt;br /&gt;
&lt;br /&gt;
class GoogleSpreadsheet:&lt;br /&gt;
	&amp;#039;&amp;#039;&amp;#039; An iterable google spreadsheet object.  Each row is a dictionary with an entry for each field, keyed by the header.  GData libraries from Google must be installed.&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	def __init__(self, spreadsheet_id, worksheet_id, user=&amp;#039;programmer@gersteinlab.org&amp;#039;, password=&amp;#039;alpaca&amp;#039;, source=&amp;#039;&amp;#039;):&lt;br /&gt;
		gd_client = gdata.spreadsheet.service.SpreadsheetsService()&lt;br /&gt;
		gd_client.email = user&lt;br /&gt;
		gd_client.password = password&lt;br /&gt;
		gd_client.source = source&lt;br /&gt;
		gd_client.ProgrammaticLogin()&lt;br /&gt;
		&lt;br /&gt;
		self.count = 0&lt;br /&gt;
		self.rows = self.formRows(gd_client.GetListFeed(spreadsheet_id, worksheet_id))&lt;br /&gt;
		&lt;br /&gt;
	def formRows(self, ListFeed):&lt;br /&gt;
		rows = []&lt;br /&gt;
		for entry in ListFeed.entry:&lt;br /&gt;
			d = {}&lt;br /&gt;
			for key in entry.custom.keys():&lt;br /&gt;
				d[key] = entry.custom[key].text&lt;br /&gt;
			rows.append(d)&lt;br /&gt;
		return rows&lt;br /&gt;
			&lt;br /&gt;
	def __iter__(self):&lt;br /&gt;
		return self&lt;br /&gt;
		&lt;br /&gt;
	def next(self):&lt;br /&gt;
		if self.count &amp;gt;= len(self.rows):&lt;br /&gt;
			self.count = 0&lt;br /&gt;
			raise StopIteration&lt;br /&gt;
		else:&lt;br /&gt;
			self.count += 1&lt;br /&gt;
			return self.rows[self.count - 1]&lt;br /&gt;
	&lt;br /&gt;
	def __getitem__(self, item):&lt;br /&gt;
		return self.rows[item]&lt;br /&gt;
		&lt;br /&gt;
	def __len__(self):&lt;br /&gt;
		return len(self.rows)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Public</name></author>
	</entry>
</feed>