В настоящее время я пишу в файл журнала следующим классическим способом;чтобы записать мои значения, которые заполняются и обрабатываются в другом месте моего приложения.
Когда я изменяю расширение файла на .csv, он выводит за пределы ячеек, грязный.
old_stdout = sys.stdout
log_file = open("./logs/metrics.log","w") # I want this to be excel instead, when I change to csv it outputs outside of cells, messy
sys.stdout = log_file
# this to be one excel row (or record)
print(f"Total Records Found #{total_records} records") # this to be excel cell
print(f"Records Processing #{num_valid_records} records") # this to be excel cell
print(f"Records Deemed Invalid (skipped) #{num_invalid_records} records") # this to be excel cell
success_rate = num_valid_records / total_records * 100
print("Sucess Rate:") # this to be excel cell
print(success_rate) # this to be excel cell
тогда это печатается так: (но как мне сопоставить это с ячейками Excel?)
Total Records Found #351 records
Records Processing #350 records
Records Deemed Invalid (skipped) #1 records
Sucess Rate:
99.71509971509973
Мне интересно;как я могу вместо этого распечатать их в файл Excel, в ячейки в виде одной строки