Example #1
0
def gen_xlsx(list_main, stats_dem, stats_lifestyle, stats_reach, workbook,
             name):
    sheet_dict = {}
    sheet_count = 1

    ##Each URL in the provided input file
    for site in list_main:
        sheet_dict[site] = workbook.new_sheet(site)
        sheet_dict[site].cell(coords=(0, 0), value=site)

        sheet_dict[site].cell(coords=(2, 0), value='Demographic Stats')
        sheet_dict[site].cell(coords=(2, 3), value='Reach Stats')
        sheet_dict[site].cell(coords=(2, 6), value='LifeStyle Stats')

        sheet_dict[site].cell(coords=(2, 1), value='%')
        sheet_dict[site].cell(coords=(2, 4), value='Monthly Uniques')
        sheet_dict[site].cell(coords=(2, 7), value='Affinity')

        ##Demographic Stats
        row_dem = 2
        col_dem = 0
        for key1 in stats_dem[site].iterkeys():
            sheet_dict[site].cell(coords=(row_dem, col_dem), value=key1)  ##Key
            sheet_dict[site].cell(coords=(row_dem, col_dem + 1),
                                  value=stats_dem[site][key1])  ##Value
            row_dem += 1

        ##Reach Stats - Not stored in list, not dict
        row_reach = 3
        col_reach = 3
        for key2 in stats_reach[site]:
            if row_reach == 3:
                sheet_dict[site].cell(coords=(row_reach, col_reach),
                                      value='US')  ##Key
            elif row_reach == 4:
                sheet_dict[site].cell(coords=(row_reach, col_reach),
                                      value='Global')  ##Key
            else:
                sheet_dict[site].cell(coords=(row_reach, col_reach),
                                      value='N/A')  ##Key
            sheet_dict[site].cell(coords=(row_reach, col_reach + 1),
                                  value=key2)  ##Value
            row_reach += 1

        ##Lifestyle Stats
        row_lifestyle = 3
        col_lifestyle = 6

        for w in sorted(stats_lifestyle[site].items(),
                        key=lambda (k, v): (v, k),
                        reverse=True):
            sheet_dict[site].cell(coords=(row_lifestyle, col_lifestyle),
                                  value=w[0])  ##Key
            sheet_dict[site].cell(coords=(row_lifestyle, col_lifestyle + 1),
                                  value=w[1])  ##Value
            row_lifestyle += 1

    sheet_count += 1
    save(workbook, name + '.xlsx')
Example #2
0
def main():
    workbook = xlsx.Workbook()
    sheet1 = workbook.new_sheet('Sheet 1')
    sheet1.cell('B1', value=7)
    sheet1.cell('C1', value=8)
    sheet1.cell('D1', value=9)
    formula = sheet1.formula('B1 + C1', shared=True)
    sheet1.cell('D2', formula)  # master
    sheet1.cell('E2', formula)  # shared, references the master formula
    xlsx.save(workbook, 'test.xlsx')  # save local file
def benchmark_xlsxcessive():
    from xlsxcessive import xlsx as xcessive

    workbook = xcessive.Workbook()
    sheet = workbook.new_sheet('Sheet1')

    for row, value in izip(xrange(ROWS), VALUES):
        for column in xrange(COLUMNS):
            sheet.cell(coords=(row, column), value=value)

    xcessive.save(workbook, 'benchmark_xlsxcessive.xlsx')
Example #4
0
def benchmark_xlsxcessive():
    from xlsxcessive import xlsx as xcessive

    workbook = xcessive.Workbook()
    sheet = workbook.new_sheet('Sheet1')

    for row, value in zip(range(ROWS), VALUES):
        for column in range(COLUMNS):
            sheet.cell(coords=(row, column), value=value)

    xcessive.save(workbook, 'benchmark_xlsxcessive.xlsx')
def gen_xlsx(list_main, stats_dem, stats_lifestyle, workbook, name):
	sheet_dict = {}
	sheet_dict['Research'] = workbook.new_sheet('Research')
	
	site_row = 3; index_dem = 1; 
	dem_dict = {}
	ls_dict = {}
	
	##Determine How many distinct Demographic fields are present
	dem_max_dict = []; dem_max_index = 1
	for site2 in list_main:
		for key_dem in stats_dem[site2].iterkeys():
			if	key_dem not in dem_max_dict:
				dem_max_dict.append(key_dem)
				dem_max_index +=1
	
	##Each URL in the provided input file
	for site in list_main:
		sheet_dict['Research'].cell(coords=(site_row,0), value=site)
		
		##Demographic Info
		for key1 in stats_dem[site].iterkeys():
		
			##Check if Parameter has been added
			if key1 not in dem_dict.keys():
				sheet_dict['Research'].cell(coords=(2,index_dem), value=key1) ## Add Key
				sheet_dict['Research'].cell(coords=(site_row,index_dem), value=stats_dem[site][key1]) ##Value
				dem_dict[key1] = index_dem
				index_dem +=1
			else:
				prev_index = dem_dict[key1] ##index of parameter that has been added already
				sheet_dict['Research'].cell(coords=(site_row,prev_index), value=stats_dem[site][key1]) ##Value
		
		index_ls = dem_max_index + 2; prev_index = -1
		##Lifestyle Stats
		for key2 in stats_lifestyle[site].iterkeys():
		
			##Check if Parameter has been added
			if key2 not in ls_dict.keys():
				sheet_dict['Research'].cell(coords=(2,index_ls), value=key2) ## Add Key
				sheet_dict['Research'].cell(coords=(site_row,index_ls), value=stats_lifestyle[site][key2]) ##Value
				ls_dict[key2] = index_ls
				index_ls +=1
			else:
				prev_index = ls_dict[key2] ##index of parameter that has been added already
				sheet_dict['Research'].cell(coords=(site_row,prev_index), value=stats_lifestyle[site][key2]) ##Value
			
		site_row +=1
	save(workbook, name + '.xlsx')
Example #6
0
def gen_xlsx(list_main, stats_dem, stats_lifestyle, stats_reach, workbook, name):
	sheet_dict = {}
	sheet_count = 1
	
	##Each URL in the provided input file
	for site in list_main:
		sheet_dict[site] = workbook.new_sheet(site)
		sheet_dict[site].cell(coords=(0,0), value=site)
		
		sheet_dict[site].cell(coords=(2,0), value = 'Demographic Stats')
		sheet_dict[site].cell(coords=(2,3), value = 'Reach Stats')
		sheet_dict[site].cell(coords=(2,6), value = 'LifeStyle Stats')
		
		sheet_dict[site].cell(coords=(2,1), value = '%')
		sheet_dict[site].cell(coords=(2,4), value = 'Monthly Uniques')
		sheet_dict[site].cell(coords=(2,7), value = 'Affinity')
		
		##Demographic Stats
		row_dem = 2; col_dem = 0
		for key1 in stats_dem[site].iterkeys():
			sheet_dict[site].cell(coords=(row_dem,col_dem), value=key1) ##Key
			sheet_dict[site].cell(coords=(row_dem,col_dem + 1), value=stats_dem[site][key1]) ##Value
			row_dem += 1
		
		##Reach Stats - Not stored in list, not dict
		row_reach = 3; col_reach = 3
		for key2 in stats_reach[site]:
			if row_reach == 3:
				sheet_dict[site].cell(coords=(row_reach,col_reach), value='US') ##Key
			elif row_reach == 4:
				sheet_dict[site].cell(coords=(row_reach,col_reach), value='Global') ##Key
			else:
				sheet_dict[site].cell(coords=(row_reach,col_reach), value='N/A') ##Key
			sheet_dict[site].cell(coords=(row_reach,col_reach+1), value=key2) ##Value
			row_reach +=1	

		##Lifestyle Stats
		row_lifestyle = 3; col_lifestyle = 6	
			
		for w in sorted(stats_lifestyle[site].items(), key=lambda(k,v):(v,k), reverse=True):
			sheet_dict[site].cell(coords=(row_lifestyle,col_lifestyle), value=w[0]) ##Key
			sheet_dict[site].cell(coords=(row_lifestyle,col_lifestyle + 1), value=w[1]) ##Value
			row_lifestyle +=1	
			
	sheet_count +=1	
	save(workbook, name + '.xlsx')
''' print Symptom Info to excel file '''
rindex = 1
cindex = 0


for record in results:
    for fieldname in fieldnames :
        ws.cell(coords=(rindex, cindex,  ), value = record[fieldname] )
        cindex += 1
    rindex += 1
    cindex = 0
    print  ".",

print " "
curdir = os.path.abspath(os.curdir)

print "Excel Saving : " + curdir + "\\" +  outputexcel
from xlsxcessive.xlsx import save
save(wb,  outputexcel)



print "Processing End ....."
exit()





Example #8
0
    cindex += 1
    if sum_total_count != 0 :
        ws.cell(coords=(rindex, cindex,  ),  value = sum_total_time/sum_total_count )
    else :
        ws.cell(coords=(rindex, cindex,  ),  value = 0 )
    rindex += 1 
    cindex = 0 
    print ".",
    
print "."    
    
''' save the  AppAccum'''

excelExceptPath = "AppAccum" + "_" +  modelname + ".xlsx"
print "Saving ressult to Excel file : ", excelExceptPath
save(wb,  excelExceptPath )
print "Saved...."


''' ====================================================================================='''




endtime =  datetime.now()
print endtime
print " elasped time is : ", endtime - starttime

print "Proces End ....."

Jobfinished()
Example #9
0
            ws.cell(coords=(rindex, cindex,  ),  value = strh )
        else:
            ws.cell(coords=(rindex, cindex,  ),  value = dictSVClogs[fieldname] )

        cindex += 1

    rindex += 1
    cindex = 0
    print  ".",

print " "
curdir = os.path.abspath(os.curdir)
excelsummary = excelsavingname + "_" + "SVCsummary" + "_" +  period + ".xlsx"
print "Excel Saving : " + curdir + "\\" +  excelsummary

save(wb,  excelsummary )

wb = 0



''' ========================= MLT LOG ======================================='''
''' Build the summary of model of the MLT  '''

wb = Workbook()
ws = wb.new_sheet(period) # insert at the end (default)

rindex = 0
cindex = 0

''' first, insert field name to row0 '''
Example #10
0
def gen_xlsx(list_main, stats_dem, stats_lifestyle, workbook, name):
    sheet_dict = {}
    sheet_dict['Research'] = workbook.new_sheet('Research')

    site_row = 3
    index_dem = 1
    dem_dict = {}
    ls_dict = {}

    ##Determine How many distinct Demographic fields are present
    dem_max_dict = []
    dem_max_index = 1
    for site2 in list_main:
        for key_dem in stats_dem[site2].iterkeys():
            if key_dem not in dem_max_dict:
                dem_max_dict.append(key_dem)
                dem_max_index += 1

    ##Each URL in the provided input file
    for site in list_main:
        sheet_dict['Research'].cell(coords=(site_row, 0), value=site)

        ##Demographic Info
        for key1 in stats_dem[site].iterkeys():

            ##Check if Parameter has been added
            if key1 not in dem_dict.keys():
                sheet_dict['Research'].cell(coords=(2, index_dem),
                                            value=key1)  ## Add Key
                sheet_dict['Research'].cell(
                    coords=(site_row, index_dem),
                    value=stats_dem[site][key1])  ##Value
                dem_dict[key1] = index_dem
                index_dem += 1
            else:
                prev_index = dem_dict[
                    key1]  ##index of parameter that has been added already
                sheet_dict['Research'].cell(
                    coords=(site_row, prev_index),
                    value=stats_dem[site][key1])  ##Value

        index_ls = dem_max_index + 2
        prev_index = -1
        ##Lifestyle Stats
        for key2 in stats_lifestyle[site].iterkeys():

            ##Check if Parameter has been added
            if key2 not in ls_dict.keys():
                sheet_dict['Research'].cell(coords=(2, index_ls),
                                            value=key2)  ## Add Key
                sheet_dict['Research'].cell(
                    coords=(site_row, index_ls),
                    value=stats_lifestyle[site][key2])  ##Value
                ls_dict[key2] = index_ls
                index_ls += 1
            else:
                prev_index = ls_dict[
                    key2]  ##index of parameter that has been added already
                sheet_dict['Research'].cell(
                    coords=(site_row, prev_index),
                    value=stats_lifestyle[site][key2])  ##Value

        site_row += 1
    save(workbook, name + '.xlsx')