Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import xlwt
- import xlrd
- import random
- from xlutils.copy import copy
- def Datos_dic_dic(f1):
- for i in range(f1):
- Datos[str(int(sheet.cell_value(i+1, 0)))] = {}
- #Para DNI
- Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 1))] = str(int(sheet.cell_value(i+1, 1)))
- #Para APELLIDOS
- Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 2))] = str(sheet.cell_value(i+1, 2))
- #Para NOMBRES
- Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 3))] = str(sheet.cell_value(i+1, 3))
- #Para SALDO
- Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 4))] = str(int(sheet.cell_value(i+1, 4)))
- #Para ESTADO
- Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 5))] = str(sheet.cell_value(i+1, 5))
- #Para CONTRASEÑA
- Datos[str(int(sheet.cell_value(i+1, 0)))][str(sheet.cell_value(0, 6))] = str(int(sheet.cell_value(i+1, 6)))
- print(Datos)
- return Datos
- def Cuentas_mov_dic_dic(g1):
- for i in range(g1//3):
- Cuentas_mov[str(int(movimientos.cell_value(0,(3*i)+2)))] = {}
- for j in range(len(movimientos.col_values(0))-1): #PONER LA WBD CON UN IF COMO EL PRIMERO PARA COGER CADA UNO
- Cuentas_mov[str(int(movimientos.cell_value(0,(3*i)+2)))]['CUENTA DESTINO'] = movimientos.col_values(0) #['', 1.0, 1.0, 1.0, 1.0, 2.0]
- Cuentas_mov[str(int(movimientos.cell_value(0,(3*i)+2)))]['MONTO DEPOSITADO'] = movimientos.col_values(1) #['', 1.0, 1.0, 1.0, 1.0, 2.0]
- for k in range(len(movimientos.col_values(2))-1):
- Cuentas_mov[str(int(movimientos.cell_value(0,(3*i)+2)))]['RETIRO'] = movimientos.col_values(2) ##['cuenta', 1.0, 1.0, 1.0, 1.0, 2.0]
- print(Cuentas_mov)
- #COLOCAR UN IF SI EL ELEMENTO DE LA LISTA ESTA VACIO, O SEA SI ES '' SI ES ASÍ ELIMINARLA DE LA LISTA CON REMOVE. etc
- def Aperturar_cuenta():
- cuentaran = str(random.randrange(999999))
- print('Por favor ingrese los datos solicitados...')
- print('Su nuevo número de cuenta es: ', cuentaran, end = '')
- print()
- dni = input('DNI: ')
- apellidos = input('Apellidos: ')
- nombres = input('Nombres: ')
- saldo = input('Saldo que abonará a su cuenta: ')
- estado = input('Estado de su cuenta (Bloqueada(B) o Activa(A)): ')
- if estado == 'B':
- estado = 'BLOQUEADA'
- else:
- estado = 'ACTIVA'
- contra = input('Ingrese su nueva contraseña (4 dígitos): ')
- Datos[cuentaran] = {}
- wb_sheet.write(f1+1, 0, cuentaran)
- Datos[cuentaran]['DNI'] = str(dni)
- wb_sheet.write(f1+1, 1, dni)
- Datos[cuentaran]['APELLIDOS'] = str(apellidos)
- wb_sheet.write(f1+1, 2, apellidos)
- Datos[cuentaran]['NOMBRES'] = str(nombres)
- wb_sheet.write(f1+1, 3, nombres)
- Datos[cuentaran]['SALDO'] = str(saldo)
- wb_sheet.write(f1+1, 4, saldo)
- Datos[cuentaran]['ESTADO'] = str(estado)
- wb_sheet.write(f1+1, 5, estado)
- Datos[cuentaran]['CONTRASENA'] = str(contra)
- wb_sheet.write(f1+1, 6, contra)
- wb.save('BaseDatos.xls')
- modificar_variable_global()
- Inicio()
- def modificar_variable_global():
- global f1
- f1 = f1+1
- def Inicio():
- bienvenida1 = 'BIENVENIDO AL BANCO BRICHE'
- print(bienvenida1.center(58, '~'))
- print('''
- 1) Ya tengo una cuenta 2) Aperturar una cuenta
- ''')
- print('Inserte una opción: ', end= '')
- inicio = int(input())
- print()
- if inicio == 2:
- Aperturar_cuenta()
- else:
- Verificar_datos()
- def Menu(numeroveri):
- print('''
- 1) Realizar depósito 2) Realizar retiro 3) Bloquear/Desbloquear cuenta
- 4) Cerrar cuenta 5) Consultar saldo 6) Movimientos
- ''')
- print('Inserte un número: ', end= '')
- inicio = int(input())
- print()
- if inicio == 1:
- Realizardeposito(numeroveri)
- def Verificar_datos():
- print()
- numeroveri = str(input('Inserte su número de cuenta: '))
- print()
- dniveri = str(input('Inserte DNI: '))
- if numeroveri in Datos and Datos[numeroveri]['DNI'] == dniveri:
- print('Datos correctos')
- nombre_bienvenida = Datos[numeroveri]['NOMBRES']
- apellido_bienvenida = Datos[numeroveri]['APELLIDOS']
- print(f'Bienvenido {nombre_bienvenida} {apellido_bienvenida}')
- Menu(numeroveri)
- else:
- print('Datos incorrectos')
- regres = input('¿Desea continuar? (SI O NO): ')
- if regres == 'SI':
- Verificar_datos()
- if regres == 'NO':
- print()
- print()
- Inicio()
- while regres != 'SI' or regres != 'NO':
- regres = input('Coloque solamente SI O NO: ')
- if regres == 'SI':
- Verificar_datos()
- if regres == 'NO':
- Inicio()
- #def Relizardeposito(numeroveri):
- file_loc = 'BaseDatos.xls'
- Datos = {}
- #En este dic esta tod0 lo que es movimientos
- # {cuenta1 : {cuenta destino : [], monto depositado : [], retiros hechos : []},
- # cuenta2 : {cuenta destino : [], monto depositado : [], retiros hechos : []}}
- Cuentas_mov = {}
- workbook = xlrd.open_workbook(file_loc)
- sheet = workbook.sheet_by_index(0)
- #PARA HOJA MOVIMIENTO MODIFICAR
- movimientos = workbook.sheet_by_index(1)
- f1 = sheet.nrows - 1
- wb = copy(workbook)
- g1 = movimientos.ncols
- wb_sheet = wb.get_sheet(0)
- #PARA HOJA MOVIMIENTOS MODIFICAR
- wb_movimientos = wb.get_sheet(1)
- Datos_dic_dic(f1)
- Cuentas_mov_dic_dic(g1)
- Inicio()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement