Thursday, August 16, 2012

Load address table into a database


import sqlite3

#Strips the unwanted text from address and stores it in a database.
cl=open("customerlist.txt")
con=sqlite3.connect("customer2.db")
cur=con.cursor()

for row in cl:
 
    address=row
    address.lstrip()
    add1=address.split()
    #print(add1[0:4])

    cur.execute("CREATE TABLE IF NOT EXISTS cleantable(hsenumber text,dir text,street text, prefix text)")
    cur.execute("INSERT INTO cleantable values(?,?,?,?)",add1[0:4])

con.commit()

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Biking helps me to cope with life.