Python- Regex or other method to get specific words

Question:

I need a way to put the "column" names in a list, using regex or other method in python.

.create table [‘IIQStatusContaInfo’] ingestion json mapping ‘IIQStatusContaInfo_mapping’ ‘[{"column":"DataColetaConta", "Properties":{"Path":"$[‘DataColetaConta’]"}},{"column":"Chave", "Properties":{"Path":"$[‘Chave’]"}},{"column":"CodBIRH", "Properties":{"Path":"$[‘CodBIRH’]"}},{"column":"NomeConta", "Properties":{"Path":"$[‘NomeConta’]"}},{"column":"StatusRecurso", "Properties":{"Path":"$[‘StatusRecurso’]"}},{"column":"IdentidadeAtivo", "Properties":{"Path":"$[‘IdentidadeAtivo’]"}},{"column":"SituacaoBIRH", "Properties":{"Path":"$[‘SituacaoBIRH’]"}},{"column":"DataColeta", "Properties":{"Path":"$[‘DataColeta’]"}}]’

Output it has to be something like this:

[‘DataColetaConta’, ‘Chave’, ‘CodBIRH’, ‘NomeConta’, …]

Asked By: Leonardo Alves

||

Answers:

import re

txt = ".create table ['IIQStatusContaInfo'] ingestion json mapping 'IIQStatusContaInfo_mapping' '[{"column":"DataColetaConta", "Properties":{"Path":"$['DataColetaConta']"}},{"column":"Chave", "Properties":{"Path":"$['Chave']"}},{"column":"CodBIRH", "Properties":{"Path":"$['CodBIRH']"}},{"column":"NomeConta", "Properties":{"Path":"$['NomeConta']"}},{"column":"StatusRecurso", "Properties":{"Path":"$['StatusRecurso']"}},{"column":"IdentidadeAtivo", "Properties":{"Path":"$['IdentidadeAtivo']"}},{"column":"SituacaoBIRH", "Properties":{"Path":"$['SituacaoBIRH']"}},{"column":"DataColeta", "Properties":{"Path":"$['DataColeta']"}}]'"
x = re.findall(""column":"(.+?)"", txt)

print(x)
Answered By: Jordan
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.