code: def _detect_encoding(data=None):
      
      import locale
      enc_list = ['utf-8', 'latin-1', 'iso8859-1', 'iso8859-2',
                  'utf-16', 'cp720']
      code = locale.getpreferredencoding(False)
      if data is None:
          return code
      if code.lower() not in enc_list:
          enc_list.insert(0, code.lower())
      for c in enc_list:
          try:
              for line in data:
                  line.decode(c)
          except (UnicodeDecodeError, UnicodeError, AttributeError):
              continue
          return c
      print("Encoding not detected. Please pass encoding value manually")
docs: Return the default system encoding. If data is passed, try
      to decode the data with the default system encoding or from a short
      list of encoding types to test.
  
      Args:
          data - list of lists
      Returns:
          enc - system encoding