0
I have a code that sends information to a csv. When it runs the first time it writes the file normally, but when it runs the second time it should add a new line in the file it ends up overwriting the whole file:
with open('\\offline.csv', 'a', encoding='utf-8', newline='') as f:
try:
writer = csv.writer(f)
writer.writerow((hw_Processador(), hw_Fabricante_PlacaMae(), hw_Modelo_PlacaMae(), hw_NS_PlacaMae(), sis_HostName(), sis_SistemaOperacional(), sis_Data_Instalacao(), sis_Dominio(), sis_Arquitetura(), sis_Usuario_Atual(), rede_IPV4(), rede_MacAddress(), rede_DNS(), hw_Memoria_RAM(), hw_HD(), nome_tecnico, local_mapeamento))
print('SEM CONEXAO! ARQUIVO CSV GERADO.')
finally:
f.close()
Would anyone have any idea what might be going on?
For what tested here the code is working normally. Can elaborate a [mcve]?
– Woss
@Andersoncarloswoss was doing minimal reproducible example and discovered the error during the process. Thank you very much, it was a function within my code.
– Algeu Junior
@Algeujunior You could put the answer to the problem.
– danieltakeshi