Good afternoon!
I have a problem and need help, I'm working with 3 distinct lists that should be added to a dictionary, but so I can capture all the values without one overwriting the other, I need to concatenate those 3 lists. I know that using ex: list1.extend(list2)
, I can concatenate, but I do not know if the same applies to concatenating multiple lists, is there any other way to do this concatenation? It follows the structure of the code, already showing the dictionary.
arrayDisciplinas = []
if response.xpath('//*[contains(a,"PDL")]//following-sibling::div//text()[not(re:test(.,"^\s+$"))]').extract() is not None:
for linha in response.xpath('//*[contains(a,"PDL")]//following-sibling::div//text()[not(re:test(.,"^\s+$"))]').extract():
disc = Disciplina()
disc.set_all()
if linha is not None:
disc['Nome'] = linha.encode('utf-8')
arrayDisciplinas.append(dict(disc))
if len(arrayDisciplinas) > 0:
disciplina = arrayDisciplinas
arrayDisciplinas2 = []
if response.xpath('//*[contains(a,"CLEO ESP")]//following-sibling::div//text()[not(re:test(.,"^\s+$"))]').extract() is not None:
for linha in response.xpath('//*[contains(a,"CLEO ESP")]//following-sibling::div//text()[not(re:test(.,"^\s+$"))]').extract():
disc2 = Disciplina()
disc2.set_all()
if linha is not None:
disc2['Nome'] = linha.encode('utf-8')
arrayDisciplinas2.append(dict(disc2))
if len(arrayDisciplinas) > 0:
disciplina2 = arrayDisciplinas2
arrayDisciplinas3 = []
if response.xpath('//*[contains(a,"CLEO ESTRUTURANTE")]//following-sibling::div//text()[not(re:test(.,"^\s+$"))]').extract() is not None:
for linha in response.xpath('//*[contains(a,"CLEO ESTRUTURANTE")]//following-sibling::div//text()[not(re:test(.,"^\s+$"))]').extract():
disc3 = Disciplina()
disc3.set_all()
if linha is not None:
disc3['Nome'] = linha.encode('utf-8')
arrayDisciplinas3.append(dict(disc3))
if len(arrayDisciplinas) > 0:
disciplina3 = arrayDisciplinas3
disciplina.extend(disciplina2)
item['Disciplinas'] = disciplina3