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’, …]
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)
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’, …]
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)