title: Edit Content of a file inside zip file
body: <p>I have lots of zip archive with text files in them. I need to find and modify a specific text in the files. However I managed to search for all the relevant lines in the files using:</p>
  
  <pre><code>import os
  import zipfile
  from glob import glob
  
  files = []
  pattern   = "*.zip"
  for dir,_,_ in os.walk(r'X:\zips'):
      files.extend(glob(os.path.join(dir,pattern)))
  
      for file in  files:
          root = zipfile.ZipFile(file, "r")
          for name in root.namelist():
              for line in root.read(name).split("\n"):
                  if line.find("keyword") &gt;= 0:
                     print line
  </code></pre>
  
  <p>I know that I can replace the keyword within the line. But how can I save it "inplace" without writing all the other text files to the hdd, delete old zip and create a new one?</p>