Aug-21-2018, 09:13 AM
hi I have a database which looks like this image
i have a csv which has two columns City and Main_city. I want to update Main_City against the City column from csv into database but without damaging other data into the database. How can i do this?
I do not know the logic behind it.
below are my codes:
i have a csv which has two columns City and Main_city. I want to update Main_City against the City column from csv into database but without damaging other data into the database. How can i do this?
I do not know the logic behind it.
below are my codes:
import csv data_obj = {} def readfiles(): f = open("city.csv", "r") data = f.read() lst = data.split("\n") for i in range(1, len(lst)): val = lst[i].split(",") data_obj[val[0]] = val[1] #print(data_obj[val[0]]) print(data_obj) readfiles() conn = sqlite3.connect('99_data_increment.db') c = conn.cursor() c.execute("CREATE TABLE IF NOT EXISTS crawled (id INTEGER PRIMARY KEY, State , XID , Project_Name , City , Main_City , Registration_Number , Promoter_Name , Rera_URL , PDF_text, Crawled_Date , Status, Names, Transaction_Date, Comments, Call_Contact_Number, Creation_Type, Builder_Website)") New_project_db.insert(statess, XID, Projectname, City, maincity, Registration_number, promotername, rera_url, blank, fdate, "CREATED", agents_names, fdate, blank, blank, blank, blank) ## didn't getting logic behindMy csv looks like this: