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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pdfplumber
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import streamlit as st
|
| 4 |
+
|
| 5 |
+
# Streamlit UI
|
| 6 |
+
|
| 7 |
+
# carro = st.text_input("Nome do veículo")
|
| 8 |
+
# st.write("Nome do veiculo é: ", carro)
|
| 9 |
+
option1 = st.selectbox(
|
| 10 |
+
"Selecione a seguradora atual",
|
| 11 |
+
('00',"01", "02", "03","04", "05", "06","07", "08", "09","10", "11", "12"))
|
| 12 |
+
option = st.selectbox(
|
| 13 |
+
"Selecione a seguradora com a melhor opcao",
|
| 14 |
+
('00',"01", "02", "03","04", "05", "06","07", "08", "09","10", "11", "12"))
|
| 15 |
+
|
| 16 |
+
if option1==option:
|
| 17 |
+
st.warning('Seguradora atual igual seguradora com melhor opcao!', icon="⚠️")
|
| 18 |
+
|
| 19 |
+
pdf_file = st.file_uploader('Choose your .pdf file', type="pdf")
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
if pdf_file is not None:
|
| 24 |
+
parameters = ['APP', 'Assistência 24 Horas', 'Valor do seguro', 'Carro Reserva',
|
| 25 |
+
'Fipe', 'Retrovisores/Faróis/Lanternas', 'Cobertura de Vidros', 'Franquia',
|
| 26 |
+
'RCF - Danos Materiais', 'RCF - Danos Corporais', 'RCF - Danos Morais']
|
| 27 |
+
data = {key: [] for key in parameters}
|
| 28 |
+
|
| 29 |
+
# Open and read the uploaded PDF file
|
| 30 |
+
with pdfplumber.open(pdf_file) as pdf:
|
| 31 |
+
lines = []
|
| 32 |
+
for page in pdf.pages:
|
| 33 |
+
text = page.extract_text()
|
| 34 |
+
if text:
|
| 35 |
+
lines.extend(text.split('\n'))
|
| 36 |
+
|
| 37 |
+
if lines:
|
| 38 |
+
indexes_list = []
|
| 39 |
+
# Loop through each line and search for the pattern
|
| 40 |
+
for index, item in enumerate(lines):
|
| 41 |
+
if item.startswith('R$'):
|
| 42 |
+
initial_index = index - 1
|
| 43 |
+
indexes_list.append(initial_index)
|
| 44 |
+
|
| 45 |
+
if indexes_list:
|
| 46 |
+
index_initial = indexes_list[0]
|
| 47 |
+
# st.text(index_initial)
|
| 48 |
+
# st.text(lines[index_initial])
|
| 49 |
+
|
| 50 |
+
# Process each line once, and extract all required fields
|
| 51 |
+
for item in lines:
|
| 52 |
+
if "APP:" in item:
|
| 53 |
+
result_app = item.split("APP:")[1]
|
| 54 |
+
result_app = result_app.replace('Selecione...', 'R$ 0,00').strip()
|
| 55 |
+
result_app = result_app.split('R$')[1:]
|
| 56 |
+
|
| 57 |
+
result_app2 = list(lines[index_initial + 7]) # This converts the 7th element of 'lines' into a list
|
| 58 |
+
# Assuming you want to split a string inside the list, you should access that string first
|
| 59 |
+
|
| 60 |
+
# For example, if 'lines[index_initial + 7]' is a single string:
|
| 61 |
+
result_app2 = lines[index_initial + 7].replace('Selecione...', 'R$ 0,00').strip() # Access the string directly
|
| 62 |
+
result_app2 = result_app2.split('R$')[1:] # Now apply the split on the string
|
| 63 |
+
|
| 64 |
+
data['APP'] = result_app+result_app2
|
| 65 |
+
|
| 66 |
+
# Extract "Assistência 24 Horas:" information
|
| 67 |
+
elif "Assistência 24 Horas:" in item:
|
| 68 |
+
result_assistencia = item.split("Assistência 24 Horas:")[1]
|
| 69 |
+
result_assistencia = (result_assistencia
|
| 70 |
+
.replace('Km Ilimitada', '10000 KM')
|
| 71 |
+
.replace('Plano M', '10000 KM')
|
| 72 |
+
.replace('km', 'KM').replace('Km', 'KM').strip())
|
| 73 |
+
result_assistencia = result_assistencia.split('KM')[:-1]
|
| 74 |
+
result_assistencia = [i.strip() for i in result_assistencia]
|
| 75 |
+
result_assistencia = ['ilimitado' if i == '10000' or i == 'Plano M' else i for i in result_assistencia]
|
| 76 |
+
|
| 77 |
+
result_assistencia2= lines[index_initial + 8]
|
| 78 |
+
result_assistencia2= (result_assistencia2
|
| 79 |
+
.replace('Km Ilimitada', '10000 KM')
|
| 80 |
+
.replace('km', 'KM').replace('Km', 'KM').strip())
|
| 81 |
+
result_assistencia2 = result_assistencia2.split('KM')[:-1]
|
| 82 |
+
result_assistencia2 = [i.strip() for i in result_assistencia2]
|
| 83 |
+
result_assistencia2 = ['ilimitado' if i == '10000' or i == 'Plano M' else i for i in result_assistencia2]
|
| 84 |
+
|
| 85 |
+
data['Assistência 24 Horas'] = result_assistencia + result_assistencia2
|
| 86 |
+
|
| 87 |
+
# Extract "Cobertura de Vidros:" information
|
| 88 |
+
elif "Cobertura de Vidros: " in item:
|
| 89 |
+
result_vidros = item.split("Cobertura de Vidros: ")[1]
|
| 90 |
+
result_vidros = result_vidros.split(' ')[1:]
|
| 91 |
+
|
| 92 |
+
result_vidros2= lines[index_initial + 9]
|
| 93 |
+
result_vidros2 = item.split("Cobertura de Vidros: ")[1]
|
| 94 |
+
result_vidros2 = result_vidros2.split(' ')
|
| 95 |
+
|
| 96 |
+
data['Cobertura de Vidros'] = result_vidros+result_vidros2
|
| 97 |
+
|
| 98 |
+
# Extract "Retrovisores/Faróis/Lanternas:" information
|
| 99 |
+
elif "Retrovisores/Faróis/Lanternas:" in item:
|
| 100 |
+
result_retrovisores = item.split("Retrovisores/Faróis/Lanternas:")[1]
|
| 101 |
+
result_retrovisores = result_retrovisores.split(' ')[1:]
|
| 102 |
+
|
| 103 |
+
result_retrovisores2=lines[index_initial + 10]
|
| 104 |
+
result_retrovisores2 = result_retrovisores2.split(' ')#[1:]
|
| 105 |
+
|
| 106 |
+
data['Retrovisores/Faróis/Lanternas'] = result_retrovisores +result_retrovisores2
|
| 107 |
+
|
| 108 |
+
# Extract "% Fipe:" information
|
| 109 |
+
elif "% Fipe: " in item:
|
| 110 |
+
result_fipe = item.split("% Fipe: ")[1]
|
| 111 |
+
result_fipe = result_fipe.replace(' ', '').split('%')[:-1]
|
| 112 |
+
|
| 113 |
+
result_fipe2=lines[index_initial + 2]
|
| 114 |
+
result_fipe2=result_fipe2.replace(' ', '').split('%')[:-1]
|
| 115 |
+
|
| 116 |
+
data['Fipe'] = result_fipe+result_fipe2
|
| 117 |
+
|
| 118 |
+
# Extract "Carro Reserva:" information
|
| 119 |
+
elif item.startswith('Carro Reserva:'):
|
| 120 |
+
result_reserva = item.split("Carro Reserva:")[1].strip().split('AR')[:-1]
|
| 121 |
+
result_reserva = [i.strip() for i in result_reserva]
|
| 122 |
+
|
| 123 |
+
result_reserva2=lines[index_initial+11]
|
| 124 |
+
result_reserva2= result_reserva2.strip().split('AR')[:-1]
|
| 125 |
+
result_reserva2 = [i.strip() for i in result_reserva2]
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
data['Carro Reserva'] = result_reserva+result_reserva2
|
| 129 |
+
|
| 130 |
+
# Extract "Carro Reserva:" information
|
| 131 |
+
elif item.startswith('Forma de Pagamento:'):
|
| 132 |
+
result_pagamento = item.split("Forma de Pagamento:")[1]
|
| 133 |
+
result_pagamento= result_pagamento.split(' ')
|
| 134 |
+
result_pagamento= [i for i in result_pagamento if i in ['Cartão','Carnê']]
|
| 135 |
+
|
| 136 |
+
result_pagamento2=lines[index_initial + 12]
|
| 137 |
+
result_pagamento2= result_pagamento2.split(' ')
|
| 138 |
+
result_pagamento2= [i for i in result_pagamento2 if i in ['Cartão','Carnê']]
|
| 139 |
+
|
| 140 |
+
data['Forma de Pagamento'] = result_pagamento+result_pagamento2
|
| 141 |
+
|
| 142 |
+
# Extract "Valor do seguro"
|
| 143 |
+
elif item.startswith('Valor do seguro'):
|
| 144 |
+
result_valor_seguro = item.split('Valor do seguro')
|
| 145 |
+
result_valor_seguro = result_valor_seguro[1].split('R$')
|
| 146 |
+
result_valor_seguro = result_valor_seguro[1:]
|
| 147 |
+
result_valor_seguro = [i.strip() for i in result_valor_seguro]
|
| 148 |
+
|
| 149 |
+
result_valor_seguro2=lines[index_initial + 1]
|
| 150 |
+
result_valor_seguro2 = result_valor_seguro2.split('R$')
|
| 151 |
+
result_valor_seguro2 = result_valor_seguro2[1:]
|
| 152 |
+
result_valor_seguro2 = [i.strip() for i in result_valor_seguro2]
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
data['Valor do seguro'] = result_valor_seguro+result_valor_seguro2
|
| 156 |
+
|
| 157 |
+
# Extract "Franquia"
|
| 158 |
+
elif item.startswith('Franquia'):
|
| 159 |
+
result_franquia = item.split('Franquia')
|
| 160 |
+
result_franquia = result_franquia[1].split('R$')
|
| 161 |
+
result_franquia = result_franquia[1:]
|
| 162 |
+
result_franquia = [i.strip() for i in result_franquia]
|
| 163 |
+
|
| 164 |
+
result_franquia2=lines[index_initial+3]
|
| 165 |
+
result_franquia2 = result_franquia2.split('R$')
|
| 166 |
+
result_franquia2 = result_franquia2[1:]
|
| 167 |
+
result_franquia2 = [i.strip() for i in result_franquia2]
|
| 168 |
+
|
| 169 |
+
data['Franquia'] = result_franquia+result_franquia2
|
| 170 |
+
|
| 171 |
+
# Extract "RCF - Danos Materiais"
|
| 172 |
+
elif item.startswith('RCF - Danos Materiais'):
|
| 173 |
+
result_rcf_materiais = item.split('RCF - Danos Materiais')
|
| 174 |
+
result_rcf_materiais = result_rcf_materiais[1].split('R$')
|
| 175 |
+
result_rcf_materiais = result_rcf_materiais[1:]
|
| 176 |
+
result_rcf_materiais = [i.strip() for i in result_rcf_materiais]
|
| 177 |
+
|
| 178 |
+
result_rcf_materiais2=lines[index_initial+4]
|
| 179 |
+
result_rcf_materiais2 = result_rcf_materiais2.split('R$')
|
| 180 |
+
result_rcf_materiais2 = result_rcf_materiais2[1:]
|
| 181 |
+
result_rcf_materiais2 = [i.strip() for i in result_rcf_materiais2]
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
data['RCF - Danos Materiais'] = result_rcf_materiais + result_rcf_materiais2
|
| 185 |
+
|
| 186 |
+
# Extract "RCF - Danos Corporais"
|
| 187 |
+
elif item.startswith('RCF - Danos Corporais'):
|
| 188 |
+
result_rcf_corporais = item.split('RCF - Danos Corporais')
|
| 189 |
+
result_rcf_corporais = result_rcf_corporais[1].split('R$')
|
| 190 |
+
result_rcf_corporais = result_rcf_corporais[1:]
|
| 191 |
+
result_rcf_corporais = [i.strip() for i in result_rcf_corporais]
|
| 192 |
+
|
| 193 |
+
result_rcf_corporais2=lines[index_initial+5]
|
| 194 |
+
result_rcf_corporais2 = result_rcf_corporais2.split('R$')
|
| 195 |
+
result_rcf_corporais2 = result_rcf_corporais2[1:]
|
| 196 |
+
result_rcf_corporais2 = [i.strip() for i in result_rcf_corporais2]
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
data['RCF - Danos Corporais'] = result_rcf_corporais + result_rcf_corporais2
|
| 200 |
+
|
| 201 |
+
# Extract "RCF - Danos Morais"
|
| 202 |
+
elif item.startswith('RCF - Danos Morais'):
|
| 203 |
+
result_rcf_morais = item.split('RCF - Danos Morais')
|
| 204 |
+
result_rcf_morais = result_rcf_morais[1].split('R$')
|
| 205 |
+
result_rcf_morais = result_rcf_morais[1:]
|
| 206 |
+
result_rcf_morais = [i.strip() for i in result_rcf_morais]
|
| 207 |
+
|
| 208 |
+
result_rcf_morais2=lines[index_initial+6]
|
| 209 |
+
result_rcf_morais2 = result_rcf_morais2.split('R$')
|
| 210 |
+
result_rcf_morais2 = result_rcf_morais2[1:]
|
| 211 |
+
result_rcf_morais2 = [i.strip() for i in result_rcf_morais2]
|
| 212 |
+
|
| 213 |
+
data['RCF - Danos Morais'] = result_rcf_morais + result_rcf_morais2
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
elif item.startswith('Item:'):
|
| 217 |
+
veiculo = item.split('Item:')
|
| 218 |
+
|
| 219 |
+
elif item.startswith('Proponente:'):
|
| 220 |
+
nome_cliente= item.split('Proponente:')
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
# for i in data.keys():
|
| 227 |
+
# st.text(f'{i}: {len(data[i])}')
|
| 228 |
+
# Create DataFrame and apply formatting
|
| 229 |
+
df = pd.DataFrame(data)
|
| 230 |
+
for i in df.columns:
|
| 231 |
+
if i in ['APP', 'Valor do seguro', 'Franquia', 'RCF - Danos Materiais', 'RCF - Danos Corporais', 'RCF - Danos Morais']:
|
| 232 |
+
df[i] = df[i].apply(lambda x: 'R$ ' + x)
|
| 233 |
+
if i == 'Assistência 24 Horas':
|
| 234 |
+
df[i] = df[i].apply(lambda x: x + ' km' if x != 'ilimitado' else x)
|
| 235 |
+
if i == 'Carro Reserva':
|
| 236 |
+
df[i] = df[i].apply(lambda x: x + ' ar')
|
| 237 |
+
if i == 'Fipe':
|
| 238 |
+
df[i] = df[i].apply(lambda x: x + '%')
|
| 239 |
+
|
| 240 |
+
df = df[['APP', 'Assistência 24 Horas', 'Carro Reserva',
|
| 241 |
+
'Fipe', 'Retrovisores/Faróis/Lanternas', 'Cobertura de Vidros',
|
| 242 |
+
'RCF - Danos Materiais', 'RCF - Danos Corporais',
|
| 243 |
+
'RCF - Danos Morais', 'Forma de Pagamento', 'Franquia', 'Valor do seguro']]
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
df.rename(columns={'APP':'Acidentes pessoais de passageiros'}, inplace=True)
|
| 247 |
+
option_selected=int(option)
|
| 248 |
+
melhor_opcao = df.loc[[option_selected]]
|
| 249 |
+
melhor_opcao.drop(columns='Forma de Pagamento',inplace=True)
|
| 250 |
+
|
| 251 |
+
option_selected_atual=int(option1)
|
| 252 |
+
atual_opcao = df.loc[[option_selected_atual]]
|
| 253 |
+
seguradora_atual = df.loc[[option_selected_atual]]
|
| 254 |
+
seguradora_atual.drop(columns='Forma de Pagamento',inplace=True)
|
| 255 |
+
# st.dataframe(seguradora_atual)
|
| 256 |
+
|
| 257 |
+
df.drop(index=option_selected,inplace=True)
|
| 258 |
+
|
| 259 |
+
df=df[['Valor do seguro','Franquia']]
|
| 260 |
+
# st.dataframe(df)
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
# Assuming df is your DataFrame
|
| 264 |
+
# for index, row in df.iterrows():
|
| 265 |
+
|
| 266 |
+
# valorSeguro=float(row[2][3:].replace('.', '').replace(',', '.'))
|
| 267 |
+
# seguradora= f'SEGURADORA {index}'+'\n'
|
| 268 |
+
# result = seguradora+'\n'.join([f'{col}: {row[col]}' for col in df.columns])
|
| 269 |
+
# st.text(result)
|
| 270 |
+
|
| 271 |
+
# st.text('\n'+'Pagamento parcelado:')
|
| 272 |
+
# for i in range(1,7):
|
| 273 |
+
# st.text(f'{i} x R$ {round(valorSeguro/i,2)}')
|
| 274 |
+
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
# st.text('__________________________')
|
| 279 |
+
all_output_atual = ''
|
| 280 |
+
|
| 281 |
+
for index, row in seguradora_atual.iterrows():
|
| 282 |
+
|
| 283 |
+
# Convert the "Valor do seguro" column to a float by removing 'R$', and replacing the comma
|
| 284 |
+
textoInicial= f'''Bom dia{nome_cliente[1]},\n\nO seguro do seu veículo está vencendo. Segue a melhor condição para a renovação da sua apólice.\n\n'''
|
| 285 |
+
valorSeguro = float(row[-1][3:].replace('.', '').replace(',', '.'))
|
| 286 |
+
seguradora = f'Veículo - {veiculo[1]}\n\nCOBERTURAS SEGURADORA {index} ATUAL:\n'
|
| 287 |
+
|
| 288 |
+
# Create the result string for the current row
|
| 289 |
+
result =textoInicial+ seguradora + '\n'.join([f'{col}: {row[col]}' for col in seguradora_atual.columns])
|
| 290 |
+
|
| 291 |
+
# Add to all_output
|
| 292 |
+
all_output_atual += result + '\n'
|
| 293 |
+
all_output_atual += '\n' + 'Pagamento parcelado:\n'
|
| 294 |
+
|
| 295 |
+
# Add parcel information
|
| 296 |
+
for i in range(1, 7):
|
| 297 |
+
# Correct the round function usage
|
| 298 |
+
valor_parcela = round(valorSeguro / i, 2)
|
| 299 |
+
valor_parcela_str = str(valor_parcela).replace('.', ',')
|
| 300 |
+
|
| 301 |
+
all_output_atual += f'{i} x R$ {valor_parcela_str}\n'
|
| 302 |
+
|
| 303 |
+
all_output = ''
|
| 304 |
+
|
| 305 |
+
for index, row in melhor_opcao.iterrows():
|
| 306 |
+
|
| 307 |
+
# Convert the "Valor do seguro" column to a float by removing 'R$', and replacing the comma
|
| 308 |
+
# textoInicial= f'''Bom dia{nome_cliente[1]},\n\nO seguro do seu veículo está vencendo. Segue a melhor condição para a renovação da sua apólice.\n\n'''
|
| 309 |
+
valorSeguro = float(row[-1][3:].replace('.', '').replace(',', '.'))
|
| 310 |
+
seguradora = f'\nCOBERTURAS DA SEGURADORA {index} COM A MELHOR CONDICAO:\n'
|
| 311 |
+
|
| 312 |
+
# Create the result string for the current row
|
| 313 |
+
result = seguradora+'\n'.join([f'{col}: {row[col]}' for col in melhor_opcao.columns])
|
| 314 |
+
|
| 315 |
+
# Add to all_output
|
| 316 |
+
all_output += result + '\n'
|
| 317 |
+
all_output += '\n' + 'Pagamento parcelado:\n'
|
| 318 |
+
|
| 319 |
+
# Add parcel information
|
| 320 |
+
for i in range(1, 7):
|
| 321 |
+
# Correct the round function usage
|
| 322 |
+
valor_parcela = round(valorSeguro / i, 2)
|
| 323 |
+
valor_parcela_str = str(valor_parcela).replace('.', ',')
|
| 324 |
+
|
| 325 |
+
all_output += f'{i} x R$ {valor_parcela_str}\n'
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
|
| 329 |
+
all_output2=''
|
| 330 |
+
for index, row in df.iterrows():
|
| 331 |
+
|
| 332 |
+
# Convert the "Valor do seguro" column to a float by removing 'R$', and replacing the comma
|
| 333 |
+
|
| 334 |
+
valorSeguro = float(row[-1][3:].replace('.', '').replace(',', '.'))
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
# Create the result string for the current row
|
| 338 |
+
result = f'''SEGURADORA {index}:\n'''+'\n'.join([f'{col}: {row[col]}' for col in df.columns])
|
| 339 |
+
|
| 340 |
+
# Add to all_output
|
| 341 |
+
all_output2 +='\n' +result + '\n'
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
# for i in range(1, 7):
|
| 345 |
+
# # Correct the round function usage
|
| 346 |
+
# valor_parcela = round(valorSeguro / i, 2)
|
| 347 |
+
# valor_parcela_str = str(valor_parcela).replace('.', ',')
|
| 348 |
+
|
| 349 |
+
# all_output2 += f'{i} x R$ {valor_parcela_str}\n'
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
st.code(all_output_atual+all_output+'\nDEMAIS SEGURADORAS PESQUISADAS:'+all_output2+'\nAo seu dispor para esclarecimentos ou alterações necessárias.')
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
pandas==2.0.3
|
| 3 |
+
pdfplumber==0.11.4
|
| 4 |
+
streamlit==1.29.0
|
| 5 |
+
|