Dear Guru, I have added def and it doesnt work Sincerly, F

Oscar oscar at westlakefinancial.com
Thu Mar 14 19:56:59 EST 2002


Dear Guru,

I have added 

def joinsplit = (join(split(lines, '"'), ' '))
        return joinsplit

to watch.txt in an effort to replace " and / with " " to no avail. Old
watch.txt works fine, without my new def.
 
Please help.

Sincerly,

     ''''\     
    ` c-@@     
    `    >     
     \_ ^
      
Frustrated and Hostile.    p.s. how far can computers fly if thrown
out a window ??




line from watch.txt ( data change to protect the indecent or innocent)

7036718,"756-74-6445","04/04/74","(555) 555-0707","(555)
555-0002","829","E PATOR ST","CHANDLER","AZ","85225","HOLE, MICHELE
M."

________________________________________________________________________________
#!/usr/bin/python

# Script is for "batch alternate input request for TRANS UNION.
# for use with a file generated from an I.Q. report from Megasys.
# watch.py version 0.3 date: Mar 12 2002  by Oscar

# new def -- the one not working
##############################################
def joinsplit = (join(split(lines, '"'), ' '))
        return joinsplit

## old stuff works fine
#############################################
def fixdate(date):
        """This is a method to format the date properly"""
        stringdate = str(date)
        year = stringdate[6:]
        month = stringdate[:2]
        day = stringdate[3:5]
        return year + month + day


def paddfield(field,length):
        padded = field + (" "*(length-len(field)))
        return padded


def fixnumeric(field,length):
        """remove garbage characters and also pads"""
        stringfield = str(field)
        fixedfield = ''
        for char in stringfield:
                if char in ('0','1','2','3','4','5','6','7','8','9'):
                        fixedfield = fixedfield + char
        padded = fixedfield + (" "*(length-len(fixedfield)))
        return padded


file=open("watch.txt")
lines = file.readlines()
for line in lines:
        list = eval('[' + line + ']')
        """subscriber specific information"""
        list.append("F ")
        list.append("0254438")
        list.append("ZN95")
        list.append("1258")

        formatted = str(list[0]) + str(list[1]) + fixdate(list[2]) +
joinsplit.fixnumeric(list[3],10) + joinsplit.fixnumeric(list[4],10) +
fixnumeric(list[5],5) + joinsplit.paddfield(list[6],30) +
paddfield(list[7],16) + list[8] + fixnumeric(list[9],9) +
paddfield(list[10],50) + list[11] + list[12] +  list[13] + list[14]

        print formatted



More information about the Python-list mailing list