mudanças relatorio ruptura
This commit is contained in:
parent
2eadd4c18f
commit
09c44480fa
@ -13,6 +13,8 @@ from datetime import datetime, time
|
|||||||
|
|
||||||
from email.mime.image import MIMEImage
|
from email.mime.image import MIMEImage
|
||||||
|
|
||||||
|
hoje = datetime.today().strftime("%d/%m/%Y")
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(r"C:\Users\joao.herculano\Documents\Enviador de email\credenciais.ini")
|
config.read(r"C:\Users\joao.herculano\Documents\Enviador de email\credenciais.ini")
|
||||||
|
|
||||||
@ -147,6 +149,22 @@ df3 = df2[df2['canal'] != "LJ"]
|
|||||||
|
|
||||||
df3 = df3.groupby(['uf', 'canal','pdv'])['quantidade_ruptura'].sum().sort_values(ascending=False).reset_index()
|
df3 = df3.groupby(['uf', 'canal','pdv'])['quantidade_ruptura'].sum().sort_values(ascending=False).reset_index()
|
||||||
|
|
||||||
|
df4 = df3.groupby('uf', as_index=False)['quantidade_ruptura'].sum()
|
||||||
|
|
||||||
|
df4['data'] = hoje
|
||||||
|
|
||||||
|
path2 = r'C:\Users\joao.herculano\OneDrive - GRUPO GINSENG\Documentos\acompanhamentos\estudo ruptura\AcompanhamentoRuptura.xlsx'
|
||||||
|
|
||||||
|
# Tenta abrir e escrever com append
|
||||||
|
with pd.ExcelWriter(path2, mode='a', engine='openpyxl', if_sheet_exists='overlay') as writer:
|
||||||
|
# Encontra a última linha preenchida
|
||||||
|
book = writer.book
|
||||||
|
sheet = writer.sheets['Sheet1'] if 'Sheet1' in writer.sheets else writer.book.active
|
||||||
|
start_row = sheet.max_row
|
||||||
|
|
||||||
|
# Escreve sem cabeçalho se não for a primeira linha
|
||||||
|
df4.to_excel(writer, index=False, header=not start_row > 1, startrow=start_row)
|
||||||
|
|
||||||
with pd.ExcelWriter(excel_path, engine='openpyxl') as writer:
|
with pd.ExcelWriter(excel_path, engine='openpyxl') as writer:
|
||||||
df2.to_excel(writer, sheet_name='Detalhado', index=False)
|
df2.to_excel(writer, sheet_name='Detalhado', index=False)
|
||||||
df3.to_excel(writer, sheet_name='Resumo', index=False)
|
df3.to_excel(writer, sheet_name='Resumo', index=False)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user