I hope you can help. I'm new to python and my question is this. I created a regex
that extracts from a file in csv the parts of the text that I want. But I want to save the output of this function in csv to compare with the start table to know how my regex
is good. Basically I get the output of my function and generate a table in csv . Can someone help me? Thanks!
Follow the code below. What I would like to do is save the pms list in csv along with some columns from the input table (df)
import re
import pandas as pd
df = pd.read_csv('C:/Users/b223902594/Documents/Sentenças/codigos/teste.csv', sep=';')
sentenca = df["descricao"] #descrição é uma das quatro colunas da tabela original.
def verificar_padroes_sentenca(lista_sentencas):
regex = r'(julgo .* dias-multa)|(julgo.*\babsolv)|(julgo .* punibilidade)| (julgo .* Lei)| (julgo .* dias multa)'
for sentenca in lista_sentencas:
pms = re.findall(regex, sentenca, flags=re.IGNORECASE)
print(pms)
Sorry for not past! I'm a newbie. Thanks!