code: def get_file_head(file_name):
      
  
      text = None
      try:
          with open(file_name, 'r', encoding='utf-8') as fh:
              text = fh.read(512000)
      except:
          try:
              with open(file_name, 'r', encoding=sys.getfilesystemencoding()) as fh:
                  text = fh.read(512000)  # pragma: nocover
          except:
              log.traceback(logging.DEBUG)
      return text
docs: Returns the first 512000 bytes of the file's contents.