title: How do I reiterate over the last iteration?
body: <p>I have an unordered dict/json object of data. In fact I have many of those, line by line in a file. There are three keys/objects in each one. I never know which of the three has the data I need to add right back onto the other two. I cannot control how the data is initially written, whether I like it or not.</p>
  
  <p>Currently I iterate over each of the three keys/objects until I find the correct key that has the fields I need. I then save them off to variables. Now, how do I go right back over the other two keys/objects that I might of already iterated over and add the fields and values back into them? As I said there are multiples of these from a file so it will just keep going on to the next one if I don't... reiterate?</p>
  
  <p>Code:</p>
  
  <pre><code>    with open(inputfile) as f:
      for line in f:
          try:
              # File is one big json object per line. Load up the current line as JSON.
              line = json.loads(line)
              for result in line['scan_result']:
                  # Check if this object's filename field has the extra data I need to parse out and palce in t he others.
                  if "meta_data" in file_result['filename']:
                      print "FOUND METADATA"
                      #print result['filename']
                      regmatch = re.match(".*meta_data_(.+?)_(.+?):(.+?)$", file_result['filename'])
                      if regmatch:
                          print "REG MATCH -------------"
                          #print regmatch.groups()
                          timecreated = regmatch.group(1)
                          author = regmatch.group(2)
                          mime_type = regmatch.group(3)
  </code></pre>
  
  <p>So as you can see, I have the data pulled out. I just need to figure out how to put it  back into the JSON objects I just iterated over. I'm open to doing this other ways to. Maybe sorting the object first and then running through it?</p>
  
  <p>If it helps, the data structure looks like this. The order of the parent is never known though. This is one "line" (json object) in the file:</p>
  
  <pre><code>{
      "filename": abc.gif
      id : 13241
      parent : 999
      interesting_file_stuff : {
          stuff : 123
          stuff2 : 456
      }
  }
  {
      "filename": hello.zip+meta_data_stuff_here
      id : 999
      parent : NA
      interesting_file_stuff : {
          stuff : 5435
          stuff2 : 24223
      }
  }
  {
      "filename": xyz.exe
      id : 8342
      parent : 999
      interesting_file_stuff : {
          stuff : 2
          stuff2 : 3232
      }
  }
  </code></pre>