title: How to convert Google spreadsheet's worksheet string id to integer index (GID)?
body: <p>To export google spreadsheet's single worksheet to CSV, integer worksheet index(GID) is required to be passed. </p>
  
  <blockquote>
    <p><a href="https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&amp;gid=%d&amp;exportFormat=csv">https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&amp;gid=%d&amp;exportFormat=csv</a></p>
  </blockquote>
  
  <p>But, where are those informations? With gdata.spreadsheets.client, I could find some string id for worksheet like "oc6, ocv, odf".</p>
  
  <pre><code>client = gdata.spreadsheets.client.SpreadsheetsClient()
  feed = client.GetWorksheets(spreadsheet, auth_token=auth_token)
  </code></pre>
  
  <p>And it returns below atom XML. (part of it)</p>
  
  <pre><code>&lt;entry gd:etag="&amp;quot;URJFCB1NQSt7ImBoXhU.&amp;quot;"&gt;
      &lt;id&gt;https://spreadsheets.google.com/feeds/worksheets/0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c/ocw&lt;/id&gt;
      &lt;updated&gt;2012-06-21T08:19:46.587Z&lt;/updated&gt;
      &lt;app:edited xmlns:app="http://www.w3.org/2007/app"&gt;2012-06-21T08:19:46.587Z&lt;/app:edited&gt;
      &lt;category scheme="http://schemas.google.com/spreadsheets/2006" term="http://schemas.google.com/spreadsheets/2006#worksheet"/&gt;
      &lt;title&gt;AchievementType&lt;/title&gt;
      &lt;content type="application/atom+xml;type=feed" src="https://spreadsheets.google.com/feeds/list/0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c/ocw/private/full"/&gt;
      &lt;link rel="http://schemas.google.com/spreadsheets/2006#cellsfeed" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/cells/0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c/ocw/private/full"/&gt;
      &lt;link rel="http://schemas.google.com/visualization/2008#visualizationApi" type="application/atom+xml" href="https://spreadsheets.google.com/tq?key=0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c&amp;amp;sheet=ocw"/&gt;
      &lt;link rel="self" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/worksheets/0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c/private/full/ocw"/&gt;
      &lt;link rel="edit" type="application/atom+xml" href="https://spreadsheets.google.com/feeds/worksheets/0AvhN_YU3r5e9dGpTWGx3UVU3MTczaXJuNEFKQjMwN2c/private/full/ocw"/&gt;
      &lt;gs:rowCount&gt;280&lt;/gs:rowCount&gt;
      &lt;gs:colCount&gt;28&lt;/gs:colCount&gt;
  &lt;/entry&gt;
  </code></pre>
  
  <p>Also I tried with sheet parameter but failed with "Invalid Sheet" error.</p>
  
  <blockquote>
    <p><a href="https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&amp;sheet=XXX&amp;exportFormat=csv">https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=%s&amp;sheet=XXX&amp;exportFormat=csv</a></p>
  </blockquote>
  
  <p>I guess there should be some magic function but could not find it. How can I convert them to integer id?? Or Can I export worksheet with string id?</p>
  
  <p>EDIT: I just made convert table with python. DIRTY but working :-( </p>
  
  <pre><code>GID_TABLE = {
      'od6': 0, 
      'od7': 1, 
      'od4': 2, 
      'od5': 3, 
      'oda': 4, 
      'odb': 5, 
      'od8': 6, 
      'od9': 7, 
      'ocy': 8, 
      'ocz': 9, 
      'ocw': 10, 
      'ocx': 11, 
      'od2': 12, 
      'od3': 13, 
      'od0': 14, 
      'od1': 15, 
      'ocq': 16, 
      'ocr': 17, 
      'oco': 18, 
      'ocp': 19, 
      'ocu': 20, 
      'ocv': 21, 
      'ocs': 22, 
      'oct': 23, 
      'oci': 24, 
      'ocj': 25, 
      'ocg': 26, 
      'och': 27, 
      'ocm': 28, 
      'ocn': 29, 
      'ock': 30, 
      'ocl': 31, 
      'oe2': 32, 
      'oe3': 33, 
      'oe0': 34, 
      'oe1': 35, 
      'oe6': 36, 
      'oe7': 37, 
      'oe4': 38, 
      'oe5': 39, 
      'odu': 40, 
      'odv': 41, 
      'ods': 42, 
      'odt': 43, 
      'ody': 44, 
      'odz': 45, 
      'odw': 46, 
      'odx': 47, 
      'odm': 48, 
      'odn': 49, 
      'odk': 50, 
      'odl': 51, 
      'odq': 52, 
      'odr': 53, 
      'odo': 54, 
      'odp': 55, 
      'ode': 56, 
      'odf': 57, 
      'odc': 58, 
      'odd': 59, 
      'odi': 60, 
      'odj': 61, 
      'odg': 62, 
      'odh': 63, 
      'obe': 64, 
      'obf': 65, 
      'obc': 66, 
      'obd': 67, 
      'obi': 68, 
      'obj': 69, 
      'obg': 70, 
      'obh': 71, 
      'ob6': 72, 
      'ob7': 73, 
      'ob4': 74, 
      'ob5': 75, 
      'oba': 76, 
      'obb': 77, 
      'ob8': 78, 
      'ob9': 79, 
      'oay': 80, 
      'oaz': 81, 
      'oaw': 82, 
      'oax': 83, 
      'ob2': 84, 
      'ob3': 85, 
      'ob0': 86, 
      'ob1': 87, 
      'oaq': 88, 
      'oar': 89, 
      'oao': 90, 
      'oap': 91, 
      'oau': 92, 
      'oav': 93, 
      'oas': 94, 
      'oat': 95, 
      'oca': 96, 
      'ocb': 97, 
      'oc8': 98, 
      'oc9': 99
  }
  </code></pre>