I
I
Ilya2021-10-29 16:15:18
Python
Ilya, 2021-10-29 16:15:18

How to append excel in python?

There is a code:

import pandas

#....getting data

data = {
'ID пользователя' : [user_id],
'Пользователь' : [username],
'Сообщение пользователя' : [message.text],
'С чата' : [chat_username],
 'Дата написания' : [send_time],
'С категории' : [category]
}

dataFrame = pandas.DataFrame(data)
dataFrame.to_excel('data.xlsx', index=False)

Works well, but overwrites the file completely. Are there ways to add it without erasing old information?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Shatalov, 2021-10-29
@stead

https://pandas.pydata.org/docs/reference/api/panda... Pay
attention to the startrow parameter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question