title: Python - file management and processing multiple zip files
body: <p>I have some zip files in a folder. I have a script to process them. The data that is to be written to a database is in a different file and its structure is as follows:</p>
  
  <pre><code>some_text;database;file_name
  some_text2;database2;file_name2
  ....
  </code></pre>
  
  <p>What is the best way to process this file? Also, an error message should be reported if there is no matching zip file name in that file.</p>
  
  <p>My current code:</p>
  
  <pre><code>filelist = glob.glob(os.path.join(rootdir, '*.zip'))
  if filelist:
      for file in filelist:
          print "Working on file ", file
          #get only file name without .zip for compare
          aa = file.split(sl)
          bb = aa[len(aa) -1]
          cc = bb.split(".")
          ime_sole = cc[0]
  
          fle = codecs.open(rootdir + sl + 'portal_schools.txt',
                            'r',encoding="cp1250")
          line = fle.readline()
  
          # Read lines 
          for line in iter(fle):
              #print line,
              a,b,c = line.split(";")
              if c == ime_sole:
                  print c
                  database = str(b)
                  #distdir = str(c)
               else:
                   print "some text"
                   return
  
  
          fle.close()
  </code></pre>
  
  <p>But this fails because it is being read line by line. If in the first line there is no match, the code stops. I need it to continue trough the file and then, after all is done, start with a new zip file.</p>