예제 #1
0
def init(path, images_path):
    offers = {}
    image_pool = images_plain_folder.init(images_path)
    with open(path, 'rb') as csvfile:
        reader = csv.reader(csvfile, delimiter=';', quotechar='"')
        row_number = -1
        for row in reader:
            row_number += 1
            if row_number > 7:
                header = row[9]
                text = row[10]
                mcc_art = row[1]
                mgb_art = row[0]
                price = row[12].replace('.', '')[:-1].replace(',', '.')
                page = row[13]
                if str(mgb_art) not in image_pool:
                    image = {
                        'text': 'place holder',
                        'image path':
                        '/home/raven/git/pages/imageDb/test1.jpg',
                        'clipping path': False
                    }
                else:
                    image = image_pool[mgb_art]

                offer = {
                    'page': page,
                    'header': header,
                    'text': text,
                    'mcc art': mcc_art,
                    'mgb art': mgb_art,
                    'price': price,
                    'image': image,
                    'image override': None,
                }
                if page not in offers:
                    offers[page] = [offer]
                else:
                    array = offers[page]
                    array.append(offer)
                    offers[page] = array

    return offers
예제 #2
0
def init(path,images_path):
	offers = {}
	image_pool = images_plain_folder.init(images_path)
	with open(path,'rb') as csvfile:
		reader = csv.reader(csvfile,delimiter=';',quotechar='"')
		row_number = -1
		for row in reader:
			row_number += 1
			if row_number > 7:
				header = row[9]
				text = row[10]
				mcc_art = row[1]
				mgb_art = row[0]
				price = row[12].replace('.','')[:-1].replace(',','.')
				page = row[13]
				if str(mgb_art) not in image_pool:
					image = {'text': 'place holder', 'image path': '/home/raven/git/pages/imageDb/test1.jpg', 'clipping path': False}
				else:
					image = image_pool[mgb_art]
				
				offer = {
						'page':page,
						'header':header,
						'text':text,
						'mcc art':mcc_art,
						'mgb art':mgb_art,
						'price':price,
						'image':image,
						'image override': None,
						}
				if page not in offers:
					offers[page] = [offer]
				else:
					array = offers[page]
					array.append(offer)
					offers[page] = array

	return offers 
예제 #3
0
def init(images_path, data_path):
    #adv init
    adv_data = {}
    path = os.path.join(data_path, 'adv.csv')
    with open(path, 'rb') as csvfile:
        reader = csv.reader(csvfile, delimiter=';', quotechar='"')
        row_number = -1
        for row in reader:
            row_number += 1
            if row_number > 7:
                adv_data[row[1]] = {
                    'header': row[9],
                    'text': row[10],
                    'image': row[0]
                }

    #PLR json
    #json_file = open(os.path.join(data_path,'plr_data.txt'))
    #json_data = json.load(json_file)
    #json_file.close()
    #plr_images = {}
    #for cataloge_id,cataloge_data in json.loads(json_data).iteritems():
    #	for prop_name,prop in cataloge_data.iteritems():
    #		if prop_name == 'Pages':
    #			for page_num,pages in prop.iteritems():
    #				for page_market,frames in pages.iteritems():
    #					for frame_num,frame_data in frames.iteritems():
    #						if frame_data['mcc_art'] != None:
    #							try:
    #								plr_images[frame_data['mcc_art'][0]] = frame_data['images'][0]
    #							except IndexError:
    #								plr_images[frame_data['mcc_art'][0]] = None
    #reg init
    offers = {}
    image_pool = images_plain_folder.init(images_path)
    path = os.path.join(data_path, '68.csv')
    print path
    with open(path, 'rb') as csvfile:
        reader = csv.reader(csvfile, delimiter=';', quotechar='"')
        row_number = -1
        for row in reader:
            row_number += 1
            if row_number > 7:
                mcc_art = row[8]
                mgb_art = row[2]

                header = adv_data[mcc_art]['header']
                text = adv_data[mcc_art]['text']
                price = row[10].replace('.', '')[:-1].replace(',', '.')
                page = row[16]
                place_on_page = row[17]
                markets = row[1]
                image_art = adv_data[mcc_art]['image']
                if str(image_art) not in image_pool:
                    image = {
                        'text': 'place holder',
                        'image path':
                        '/home/raven/git/pages/imageDb/test1.jpg',
                        'clipping path': False
                    }
                else:
                    image = image_pool[image_art]

                offer = {
                    'page': page,
                    'header': header,
                    'text': text,
                    'mcc art': mcc_art,
                    'mgb art': mgb_art,
                    'price': price,
                    'image': image,
                    'image override': None,
                    'markets': markets,
                    'feild': place_on_page
                }
                if page not in offers:
                    offers[page] = [offer]
                else:
                    array = offers[page]
                    array.append(offer)
                    offers[page] = array

    return offers
예제 #4
0
def init(images_path,data_path):
	#adv init
	adv_data = {}
	path = os.path.join(data_path,'adv.csv')	 
	with open(path,'rb') as csvfile:
		reader = csv.reader(csvfile,delimiter=';',quotechar='"')
		row_number = -1
		for row in reader:
			row_number += 1
			if row_number > 7:
				adv_data[row[1]] = {'header':row[9],
									'text':row[10],
									'image':row[0]}

	#PLR json
	#json_file = open(os.path.join(data_path,'plr_data.txt'))
	#json_data = json.load(json_file)
	#json_file.close()
	#plr_images = {}
	#for cataloge_id,cataloge_data in json.loads(json_data).iteritems():
	#	for prop_name,prop in cataloge_data.iteritems():
	#		if prop_name == 'Pages':
	#			for page_num,pages in prop.iteritems():
	#				for page_market,frames in pages.iteritems():						
	#					for frame_num,frame_data in frames.iteritems():
	#						if frame_data['mcc_art'] != None:
	#							try:
	#								plr_images[frame_data['mcc_art'][0]] = frame_data['images'][0]
	#							except IndexError:
	#								plr_images[frame_data['mcc_art'][0]] = None
	#reg init
	offers = {}
	image_pool = images_plain_folder.init(images_path)
	path = os.path.join(data_path,'68.csv')
	print path
	with open(path,'rb') as csvfile:
		reader = csv.reader(csvfile,delimiter=';',quotechar='"')
		row_number = -1
		for row in reader:
			row_number += 1
			if row_number > 7:
				mcc_art = row[8]
				mgb_art = row[2]
				
				header = adv_data[mcc_art]['header']
				text = adv_data[mcc_art]['text']				
				price = row[10].replace('.','')[:-1].replace(',','.')
				page = row[16]
				place_on_page = row[17]
				markets = row[1]
				image_art = adv_data[mcc_art]['image']
				if str(image_art) not in image_pool:
					image = {'text': 'place holder', 'image path': '/home/raven/git/pages/imageDb/test1.jpg', 'clipping path': False}
				else:
					image = image_pool[image_art]
				
				offer = {
						'page':page,
						'header':header,
						'text':text,
						'mcc art':mcc_art,
						'mgb art':mgb_art,
						'price':price,
						'image':image,
						'image override': None,
						'markets':markets,
						'feild':place_on_page
						}
				if page not in offers:
					offers[page] = [offer]
				else:
					array = offers[page]
					array.append(offer)
					offers[page] = array

	return offers