code: def unzip_file(filename):
      
  
      if filename.endswith('bz2'):
          bz2file = bz2.BZ2File(filename)
          fdn, tmpfilepath = tempfile.mkstemp()
          with closing(os.fdopen(fdn, 'wb')) as ofpt:
              try:
                  ofpt.write(bz2file.read())
              except IOError:
                  import traceback
                  traceback.print_exc()
                  LOGGER.info("Failed to read bzipped file %s", str(filename))
                  os.remove(tmpfilepath)
                  return None
  
          return tmpfilepath
  
      return None
docs: Unzip the file if file is bzipped = ending with 'bz2