Rev 224 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 09-Jun-2010@author: gaurav'''from datastore.DataAccessor import DataHelperimport sysfrom StdFormatConv.SplitBrandandModel import *from StdFormatConv.RefineModel import *import os'''Get all the themobilestore phones first.Postprocess the phones and brake the phone name column intobrand and model name respectively'''da = DataHelper()da.initxy()ds = os.sepsup_name = "mobilestore"phones = DataHelper()phones = phones.get_allmobstorephones_new()if not phones:print "Error while getting phones"sys.exit(-1)file_to_write = ds+"tmp"+ds+"themobstore_new.csv"data_file = open(file_to_write,"w")csv_data = "%s, %s, %s, %s, %s" %("brand", "model", "shown_price", "final_price", "extra_info")data_file.write(csv_data)data_file.write("\n")da.initxy()for phone in phones:unparsed_name = getunformatted(phone.name)vendor_name, phone_name,e_info = getbrandandmodel(unparsed_name)if vendor_name == "":vendor_name = "unknown"model_name,extra_info = getrefinedmodel(phone_name)extra_info = e_info + extra_infoif extra_info.endswith(','):extra_info = extra_info[0:len(extra_info)-1]da.add_models(vendor_name, model_name)extra_info = phone.extra_info + extra_infocsv_data = "%s, %s, %d, %d, %s" %(vendor_name, model_name, phone.shown_price, phone.final_price,extra_info)modId = da.get_modId(vendor_name,model_name)supId = da.get_suppId(sup_name)da.add_prices(modId, supId, phone.shown_price, phone.final_price,extra_info)data_file.write(csv_data)data_file.write("\n")data_file.close()