def parse_csv(self): csv_list = csv_to_json.convert(self.filename) options_class = Options_Resource() # for i in range(54658,54673): # options_class.delete_options(i) for row in csv_list: try: print 'Time:', datetime.datetime.time(datetime.datetime.now()) if row['Item Type'] == 'Product': option_set_id, option_id_dict = None, None product_name = row['name'] product_class = Product_Resource(row, self.brands_id_dict, self.category_id_dict) options_class = Options_Resource() Option_set_class = OptionSet_Resource() rules_class = Rules_Resoruce() sku_class = SKU_Resource() values_class = Option_Values_Resource() option_set_option_class = Option_Set_Option_Resource() rules_class = Rules_Resoruce() product_id_dict, sku_dict = {}, {} if self.in_stock_dict: sku_class.delete_SKU(self.in_stock_dict, sku_dict, product_id) product_id_dict, option_set_id = self.parse_productrow(row, product_class) product_id = product_id_dict['id'] if not product_id_dict['New']: print 'S' sku_dict = sku_class.get_product_SKU(product_id) print sku_dict rules_dict = rules_class.get_product_rules(product_id) elif 'SKU' in row['Item Type']: if row['sku'] in sku_dict: self.in_stock_dict[row['sku']] = sku_dict[row['sku']] else: if option_id_dict == None: print 'option_id_dict None' option_values_dict = {} option_id_dict = options_class.create_options(row, product_name) print 'Option ID Dict' print option_id_dict for option_type, option_id in option_id_dict.iteritems(): option_set_option_class.create_option_set_option(option_id, option_type, option_set_id) option_values_dict.update(values_class.create_option_values(option_id_dict, row)) sku_id = sku_class.create_SKU(row, product_id, option_values_dict) elif 'Rule' in row['Item Type']: if row['sku'] in sku_dict: pass else: rules_class.create_rules(row, product_id, sku_id) except: pass