I have two lists of objects and I need to select the items that have the same attribute cpf and value:
This is my object class:
class Clientes:
def __init__(self):
self.nome = ""
self.cpf = ""
self.valor = ""
self.proposta = ""
And this my main code:
from objetos import Clientes
ArquivoA = {'Cliente1': ['Antonio', '123', '150', 'a'],
'Cliente2': ['Betina', '456', '200', 'b'],
'Cliente3': ['Dagmar', '789', '300', 'c'],
'Cliente4': ['Richard', '001', '400', 'd'],
'Cliente5': ['Maria', '435', '80', 'e']}
ArquivoB = {'Cliente1': ['Antonio', '123', '150'],
'Cliente2': ['Betina', '456', '200'],
'Cliente3': ['Dagmar', '789', '250'],
'Cliente4': ['Richard', '001', '450'],
'Cliente5': ['Jose', '987', '500']}
listaA= []
listaB = []
for item in ArquivoA:
c = Clientes()
c.nome = ArquivoA[item][0]
c.CPF = ArquivoA[item][1]
c.valor = ArquivoA[item][2]
c.proposta = ArquivoA[item][3]
listaA.append(c)
print(listaA)
for item in ArquivoB:
b = Clientes()
b.nome = ArquivoB[item][0]
b.CPF = ArquivoB[item][1]
b.valor = ArquivoB[item][2]
listaB.append(c)
print(listaB)
I want to create a new list where c.CPF == b.CPF and c.value == b.value. I don't want to use double loop for this, because my real list is so big.