title: How to use Google sheet API V4 insert note in cell by python
body: <p>I don't know how to add note in a cell by Google Sheet API:
  <a href="https://developers.google.com/sheets/api/guides/values#writing_multiple_ranges" rel="nofollow noreferrer">https://developers.google.com/sheets/api/guides/values#writing_multiple_ranges</a></p>
  
  <p>I read info of Google Sheet API:  <a href="https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#CellData" rel="nofollow noreferrer">https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#CellData</a></p>
  
  <p>I also read this question but it's still not working
  <a href="https://stackoverflow.com/questions/12913874/is-it-possible-to-use-the-google-spreadsheet-api-to-add-a-comment-in-a-cell">Is it possible to use the Google Spreadsheet API to add a comment in a cell?</a></p>
  
  <p>I don't know how to set note in the value.
  I need someone help ~! 
  Thanks a lot.</p>
  
  <pre><code>from __future__ import print_function
  import httplib2
  import os
  
  from apiclient import discovery
  from oauth2client import client
  from oauth2client import tools
  from oauth2client.file import Storage
  
  try:
      import argparse
      flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
  except ImportError:
      flags = None
  
  # If modifying these scopes, delete your previously saved credentials
  # at ~/.credentials/sheets.googleapis.com-python-quickstart.json
  # Scope type --&gt; https://developers.google.com/sheets/api/guides/authorizing
  SCOPES = 'https://www.googleapis.com/auth/spreadsheets'  
  CLIENT_SECRET_FILE = 'client_secret.json'        # credentials file name
  APPLICATION_NAME = 'auto_update_caspar'
  
  
  def get_credentials():
  """Gets valid user credentials from storage.
  
  If nothing has been stored, or if the stored credentials are invalid,
  the OAuth2 flow is completed to obtain the new credentials.
  
  Returns:
      Credentials, the obtained credential.
  """
  home_dir = os.path.expanduser('~')
  credential_dir = os.path.join(home_dir, '.credentials')
  if not os.path.exists(credential_dir):
      os.makedirs(credential_dir)
  credential_path = os.path.join(credential_dir,
                                 'auto_update_client_caspar.json')
  
  store = Storage(credential_path)
  credentials = store.get()
  if not credentials or credentials.invalid:
      flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
      flow.user_agent = APPLICATION_NAME
      if flags:
          credentials = tools.run_flow(flow, store, flags)
      else: # Needed only for compatibility with Python 2.6
          credentials = tools.run(flow, store)
      print('Storing credentials to ' + credential_path)
  return credentials
  
  def main():
  """Shows basic usage of the Sheets API.
  
  Creates a Sheets API service object and prints the names and majors of
  students in a sample spreadsheet:
  https://docs.google.com/spreadsheets/d/1k7OmDU_QUrCPVmsEpWFRCj-4BOu6PcUb7-SQlA7T_8I/edit
  """
  credentials = get_credentials()
  http = credentials.authorize(httplib2.Http())
  discoveryUrl = ('https://sheets.googleapis.com/$discovery/rest?'
                  'version=v4')
  service = discovery.build('sheets', 'v4', http=http,
                            discoveryServiceUrl=discoveryUrl)
  
  spreadsheetId = '1lEJeSNe5T3rNXEEMjY4D04QkoW-ngOeiFo40_S4H4FI'
  rangeName = 'stress_temp!A3'
  
  result = service.spreadsheets().values().get(
      spreadsheetId=spreadsheetId, range=rangeName).execute()
  print (result)
  values = result.get('values', [])
  
  if not values:
      print('No data found.')
  else:
      print('Name, Major:')
      for row in values:
          # Print columns A and E, which correspond to indices 0 and 4.
          print('%s' % row[0])
  
  
  
  value_input_option = 'RAW'
  range_name = 'stress_temp!A3'
  values = [['aa']]
  data = [
      {
          'range': range_name,
          'values': values
      },
  ]`enter code here`
  body = {
    'valueInputOption': value_input_option,
    'data': data
  }
  result = service.spreadsheets().values().batchUpdate(
      spreadsheetId=spreadsheetId, body=body).execute()
  
  
  
  if __name__ == '__main__':
  main()
  </code></pre>