title: python + google drive: upload xlsx, convert to google sheet, get sharable link
body: <p>The flow of my desired program is:</p>
  
  <ol>
  <li>Upload an xlsx spreadsheet to drive (it was created using pandas <code>to_excel</code>) </li>
  <li>Convert it to Google Sheets format </li>
  <li>Specify that it is editable by anyone with the link </li>
  <li>Get the link and share it with someone who will enter information</li>
  <li>Download the completed sheet</li>
  </ol>
  
  <p>I am currently using PyDrive, which solves steps 1 and 5, but there are a few unsolved problems.</p>
  
  <p>How can I convert to google sheets format? I tried to just specify the mimeType as <code>'application/vnd.google-apps.spreadsheet'</code> when I created the file to upload with PyDrive, but that gave me an error. </p>
  
  <p>How can I set the file to be editable by anyone with the link? Once that is set, I can get the sharing link easily enough with PyDrive. </p>
  
  <p>UPDATE: conversion from xlsx to google sheets is easy with a <code>convert=True</code> flag. See below. I am still seeking a way to set the sharing settings of my new file to "anyone with the link can edit". </p>
  
  <pre><code>from pydrive.auth import GoogleAuth
  from pydrive.drive import GoogleDrive
  
  gauth = GoogleAuth()
  gauth.LocalWebserverAuth()
  drive = GoogleDrive(gauth)
  
  test_file = drive.CreateFile({'title': 'testfile.xlsx'})
  test_file.SetContentFile('testfile.xlsx')
  test_file.Upload({'convert': True})
  </code></pre>