code: def get_file_id(credentials, gfile, write_access=False):
      
      # auth for apiclient
      http = credentials.authorize(Http())
      service = discovery.build('drive', 'v3', http=http, cache_discovery=False)
  
      file_id = service.files().get(fileId='root', fields='id').execute().get('id')
  
      # folder/folder/folder/spreadsheet
      pathway = gfile.strip('/').split('/')
  
      for idx, name in enumerate(pathway):
          files = service.files().list(
              q="name = '{}' and trashed = false and '{}' in parents".format(name, file_id)).execute()['files']
          if len(files) > 0:
              # Why do you ever need to use several folders with the same name?!
              file_id = files[0].get('id')
          elif write_access == True:
              body = {
                  'mimeType': 'application/vnd.google-apps.' + ('spreadsheet' if idx == len(pathway)-1 else 'folder'),
                  'name': name,
                  'parents': [file_id]
              }
              file_id = service.files().create(body=body, fields='id').execute().get('id')
          else:
              return None
      return file_id
docs: Get file ID by provided path. If file does not exist and
          `write_access` is true, it will create whole path for you.
  
          :param credentials: provide own credentials
          :param gfile: path to Google Spreadsheet
          :param write_access: allows to create full path if file does not exist
          :type credentials: class 'oauth2client.client.OAuth2Credentials'
          :type gfile: str
          :type write_access: boolean
          :returns: file ID
          :rtype: str
  
          :Example:
  
              >>> from df2gspread.gfiles import get_file_id
              >>> from df2gspread.utils import get_credentials
              >>> gfile = '/some/folder/with/file'
              >>> credentials = get_credentials()
              >>> get_file_id(credentials=credentials, gfile=gfile, write_access=True)
              u'78asbcsSND8sdSACNsa7ggcasca8shscaSACVD'