コード例 #1
0
def formulas(hoja,writer):
#    print('Calculando totales...')
    lg.escribe_log('Calculando totales...')
    worksheet = writer.sheets[hoja]
    worksheet.write('J2', 'Total')
    worksheet.write_formula('J3', '{=SUM(D3:I3)}')
    
    worksheet.write('J7', 'Total')
    for i in range(8,11):
        form='{=SUM(D' + (str(i))+':I'+(str(i))+')}'
        worksheet.write_formula(('J'+str(i)), form)
    
    worksheet.write('J14', 'Total')
    for i in range(15,23):
        form='{=SUM(D' + (str(i))+':I'+(str(i))+')}'
        worksheet.write_formula(('J'+str(i)), form)
    
    worksheet.write('C11', 'Gran Total')
    for i in "DEFGHIJ":
        var=('{=SUM('+i+'8:'+i+'10)}')
        worksheet.write_formula((i+'11'), var)
	
    worksheet.write('C23', 'Gran Total')
    for i in "DEFGHIJ":
        var=('{=SUM('+i+'15:'+i+'22)}')
        worksheet.write_formula((i+'23'), var)
    return()
コード例 #2
0
def escribeExcel(var_fecha,hoja1,hoja2,hoja3,hoja4,hoja5,hoja6,resultado,f_est,f_FCR,f_areas,f_est_ante,f_FCR_ante,f_areas_ante,FCR_e,folios_e,backlog_e,prom_s_e1,prom_s_e2):
    #    
    # Create a Pandas Excel writer using XlsxWriter as the engine.
    writer = pd.ExcelWriter(carpeta+'reporte_'+var_fecha+'.xlsx', engine='xlsxwriter')
    # Convert the dataframe to an XlsxWriter Excel object.
    resultado.to_excel(writer, sheet_name='Acumulado')
#    
    f_est.to_excel(writer, sheet_name=hoja1, startrow = 1, startcol = 2)
    f_FCR.to_excel(writer, sheet_name=hoja1,startrow = 6, startcol = 2)
    f_areas.to_excel(writer, sheet_name=hoja1,startrow = 13, startcol = 2)
    #
    f_est_ante.to_excel(writer, sheet_name=hoja2, startrow = 1, startcol = 2)
    f_FCR_ante.to_excel(writer, sheet_name=hoja2,startrow = 6, startcol = 2)
    f_areas_ante.to_excel(writer, sheet_name=hoja2,startrow =13, startcol = 2)
    
    FCR_e.to_excel(writer, sheet_name=hoja3, startrow = 1, startcol = 2)
    folios_e.to_excel(writer, sheet_name=hoja4,startrow = 1, startcol = 2)
    
    backlog_e.to_excel(writer, sheet_name=hoja5, startrow = 1, startcol = 2)
    
    prom_s_e1.to_excel(writer, sheet_name=hoja6,startrow = 2, startcol = 2)
    prom_s_e2.to_excel(writer, sheet_name=hoja6,startrow = 12, startcol = 2)    
    
#    backlog_e.to_excel(writer, sheet_name=hoja3,startrow = 1, startcol = 2)
	# Get the xlsxwriter objects from the dataframe writer object.
#    print('Datos en excel completo...')
    lg.escribe_log('Datos en excel completo...')
    formulas(hoja1,writer)
    formulas(hoja2,writer)
    formulas1(hoja4,writer)
    porcentajes(hoja3,writer)
    modificacion_titulos(hoja6,writer)
    writer.save()
    return()
コード例 #3
0
ファイル: conexion.py プロジェクト: erickdejesus/reporte_sr
def close_conn():
    try:
        db.close()
        lg.escribe_log('** Conexion Base de Datos cerrada')
    except cx_Oracle.DatabaseError as rep:
        msg = 'Error:', str(db) + str(rep)
        #        print(msg)
        lg.escribe_log('** Error conexion' + msg)
    return ()
コード例 #4
0
ファイル: conexion.py プロジェクト: erickdejesus/reporte_sr
def open_conn():
    try:
        db = cx_Oracle.connect(usuario, passw, URL1)
        lg.escribe_log('** Conexion Base de Datos establecida')
    except cx_Oracle.DatabaseError as rep:
        msg = 'Error:', str(db) + str(rep)
        #        print(msg)
        lg.escribe_log('-- Error conexion' + msg)

    return db
コード例 #5
0
def formulas1(hoja,writer):
#    print('Calculando totales...')
    lg.escribe_log('Calculando totales 2...')
    worksheet = writer.sheets[hoja]
    worksheet.write('E2', '0-5 Días')
    worksheet.write('F2', '6-15 Días')
    worksheet.write('G2', '16-30 Días')
    worksheet.write('H2', '>30 Días')
    worksheet.write('I2', 'Total')
    
    for i in range(3,9):
        form='{=SUM(E' + (str(i))+':H'+(str(i))+')}'
        worksheet.write_formula(('I'+str(i)), form)
    
    return()
コード例 #6
0
def porcentajes(hoja,writer):
#    print('Calculando totales...')
#    format = workbook.add_format()
#
#    format.set_pattern(1)  # This is optional when using a solid fill.
#    format.set_bg_color('green')
    lg.escribe_log('Calculando porcentajes ...')
    worksheet = writer.sheets[hoja]
    worksheet.write('D2', 'CAMPAÑA')
    worksheet.write('H2', '%FCR')
    
    for i in range(3,27):
        form='{=ROUND(((F'+str(i)+'*100)/G'+str(i)+'),2)}'
        worksheet.write_formula(('H'+str(i)), form)
#        worksheet.write('A1', 'Ray', format)  
        
    return()
コード例 #7
0
def depura_Archivos(ruta):
    formato1 = "%Y%m%d"
    nombre = 'reporte_'
    log = 'log'
    archivos = []
    td = f1.dia_actual()
    rootDir = ruta
    if (td == 1) or (td == 15):
        lg.escribe_log('**Empieza la depuracion...')
        for dirName, subdirList, fileList in os.walk(rootDir):
            #            print('Directorio encontrado: %s' % dirName)
            for fname in fileList:
                archivos.append(fname)

        hoy = date.today()  # Asigna fecha actual
        lg.escribe_log('**Fecha actual ' + str(hoy))
        ultimo = hoy - timedelta(days=6)
        faux = ultimo
        lg.escribe_log('**Fecha de depuracion ' + str(ultimo))
        faux = faux.strftime(formato1)

        #       print('--'+str(hoy))
        #       print('++'+str(ultimo))
        #       print('**'+aux)
        aux = ''
        aux1 = ''
        while (ultimo <= hoy):
            for ar in archivos:
                aux = nombre + str(faux) + '.xlsx'
                aux1 = log + str(faux) + '.txt'
                if ar == aux:
                    archivos.remove(aux)
#                    print(ar+'*'+aux)
                elif ar == aux1:
                    archivos.remove(aux1)
#                    print(ar+'**'+aux1)
            ultimo = ultimo + timedelta(days=1)
            faux = ultimo
            faux = faux.strftime(formato1)
#            print(faux)

#    print(archivos)
        for ar in archivos:
            os.remove(ruta + ar)

    return ()
コード例 #8
0
def depura_ftp():
    try:
      s = ftplib.FTP(ftp_servidor, ftp_usuario, ftp_clave)
      try:
          s.cwd(ftp_raiz)
          #listamos los archivos del directorio /pub
          archivos = s.dir()
          print (archivos)
          print ('--------')
          s.quit()
          lg.escribe_log('**Se realizó correctamente la depuración en el FTP')
      except:
#          print ("No se ha podido encontrar el fichero " + fichero_origen)
            lg.escribe_log("No se ha podido encontrar el directorio")
    except:
#        print ("No se ha podido conectar al servidor " + ftp_servidor)
        lg.escribe_log("No se ha podido conectar al servidor " + ftp_servidor)
    return()
コード例 #9
0
def carga_Archivo(ruta_origen,fichero_origen,fichero_destino):
# Conectamos con el servidor
    try:
      s = ftplib.FTP(ftp_servidor, ftp_usuario, ftp_clave)
      try:
          f = open(ruta_origen+fichero_origen, 'rb')
          s.cwd(ftp_raiz)
          s.storbinary('STOR ' + fichero_destino, f)
          f.close()
          s.quit()
          lg.escribe_log('**Archivo correctamente subido a FTP')
      except:
#          print ("No se ha podido encontrar el fichero " + fichero_origen)
            lg.escribe_log("No se ha podido encontrar el fichero " + fichero_origen)
    except:
#        print ("No se ha podido conectar al servidor " + ftp_servidor)
        lg.escribe_log("No se ha podido conectar al servidor " + ftp_servidor)
    return ()
コード例 #10
0
ファイル: reporte_SR.py プロジェクト: erickdejesus/reporte_sr
grupos_f= config.get("CONSULTAS", "GRUPO_F")
var_fecha=f1.dia_reporte()
fecha_acum=fecha_acum.replace('FECHA_VAR',var_fecha)
fecha_ante=fecha_ante.replace('FECHA_VAR',var_fecha)
c_folios = reporte2.get("CONSULTAS", "FOLIOS")
c_porcentaje = reporte2.get("CONSULTAS", "PORCENTAJE")
c_backlog = reporte2.get("CONSULTAS", "BACKLOG")
c_promedio = reporte2.get("CONSULTAS", "PROMEDIO")
c_pro1 = reporte2.get("CONSULTAS", "PROM1")
c_pro2 = reporte2.get("CONSULTAS", "PROM2")
carpeta = parametros.get("CARPETA", "RUTA")
depura.valida_directorio(carpeta)
#c=db.cursor()
#print(var_fecha)
texto = '**************** Inicia el proceso del reporte '+str(var_fecha)+'************'
lg.escribe_log(texto)
db=con.open_conn()
try:
#    print(db)   
#    db=con.open_conn(user_db,pass_db,url_db)
#    print(Consulta)
    sqlt = consulta + " " + fecha_acum
#    print('Creacion consulta')
    lg.escribe_log('**Creacion consulta datos completos')
    resultado = pd.read_sql(sqlt,db,index_col=None)
    resultado.loc[resultado['AREA'].isnull(), 'AREA'] = 'Blank'
    resultado.loc[resultado['FCR'].isnull(), 'FCR'] = 'Blank'
#    print('Datos acumulados completos...')
    lg.escribe_log('Datos acumulados completos...')
    aux_sql= conteo
    fecha_acum = ' '+fecha_acum+' '