Row is updating with value from previous row

Discussion created by recurvata on Apr 21, 2014
I have a script that looks at the value of one field, OLDPLATE, and formats a string based on the format of the value in the field, and updates a second field. For the most part this works ok, but I've noticed a case where it's updating the value of one record based on the value of the preceding record, and I can't figure out why. It appears that it's not updating the value for base in the code below. The trouble value in OLDPLATE is 'A 00151F1/F2' The base should be 'A00151F1/F2', and the second elif should take care of it, as far as I can see. Any clues? Thanks.

ltrs = string.ascii_letters

        for row in rows:
                folder = row.OLDPLATE[:2].strip()
                plate = row.OLDPLATE
                base = row.OLDPLATE.split('/')[0]
                if len(folder) > 0:

                    # e.g. A 00827A/828B or A 00827A/B => A00827A.tif
                    if plate[-1] in ltrs and '/' in plate and base[-1] in ltrs:
                        fileName = base + self.extension

                    # e.g. A 00827/828A => A 00827A.tif
                    elif plate[-1] in ltrs and "/" in plate and base[-1] not in ltrs:
                        ltr = plate[-1]
                        fileName = base + ltr + self.extension

                    # e.g. A 00827/828 => A 00827.tif
                    elif plate[-1] not in ltrs and "/" in plate:
                        filename = base + self.extension

                    # e.g. A 00827 => A 00827.tif
                        fileName = plate + self.extension

                    link = os.path.join(self.baseDir, folder, fileName)
                    row.ScanLocation = link