def createAccount(record):
  """
    Create a partially populated Account record, corresponding to the 
    Company specified in the Excel record.
  """
  global importSheet, importRow
  ownerId = None
  setOwner = False
  if record['Owner First Name'] != None and len(record['Owner First Name']) > 0 and \
     record['Owner Last Name'] != None and len(record['Owner Last Name']) > 0:
    setOwner = True
   
  if setOwner:  
    result = sf.query(
      u"select Id from User where FirstName = '%s' and LastName = '%s'"                 
      % (record['Owner First Name'].replace(u"'", u"\\'") , record['Owner Last Name'].replace(u"'", u"\\'"))
    )
  
    if result.size > 1:
      print "Warning: Multiple users with name \"%s %s\" - using first found." \
        % (record['Owner First Name'], record['Owner Last Name'])
    elif result.size == 1:    
      ownerId = result.records[0].Id
    else:
      global invokingUser
      print "Warning: no owning User found for  \"%s %s\" - owner will be \"%s\" " \
        % (record['Owner First Name'], record['Owner Last Name'], invokingUser)
  
  account               = sf.generateObject('Account')
  account.Name          = record['Company']
  account.TickerSymbol  = record['Symbol']  # just used to mark records for testing
  if (setOwner and ownerId != None):
    account.OwnerId     = ownerId
  result                = sf.create(account)
  
  if result.success != True:
    global importSheet, importRow
    msg = "Error: Can't create Account record for %s, result was %s" % (str(record), result)      
    raise ImportError(msg, importSheet, importRow)
    
    
  print "New Account record for %s, Id = %s" % (account.Name, result.id)

  return result

    Create a partially populated Account record, corresponding to the 
    Company specified in the Excel record.
  
recipes/Python/577550_Custom_import_script/recipe-577550.py