title: Copy .txt files from a .tar.gz file to other directory
body: <p>I am trying to copy all the .txt files from a compressed file (this file has unknown_name_folders):
  .txt files location ---> my_path/?unknown_name_folder?/file.txt
  I want to do --->  my_path/file.txt</p>
  
  <p>I did this code, but I have this error: EOFError: Compressed file ended before the end-of-stream marker was reached. Any idea?</p>
  
  <pre><code>file=my_path+"/"+fil
  if file.endswith('.tar.gz'):
  
      tarf = tarfile.open(file, "r:gz")
      for info in tarf:
  
          if info.name.endswith('.txt'):
              print(info.name)
  
              tar = tarfile.open(file) #extracting
              tar.extractall()
              tar.close()    
              code=os.system('cp ' + my_path+'/'+info.name +' '+ file)
  </code></pre>