E
E
Ernest Vardanyan2020-06-22 13:20:18
Python
Ernest Vardanyan, 2020-06-22 13:20:18

How can I save data in Excel on a new line?

Hello. I'm parsing data and I need it to be saved as a string in an Excel file. The code opens the page, gets all the data, writes it to a table, and closes the browser, but the code itself works; after 15 seconds of timing, it opens again, parsing new data. I want the data to be from a new row in Excel. Please tell me how to implement.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vadim, 2020-06-22
@Ernest123

And what have you already written for recording in excel?

G
Grigory Boev, 2020-06-22
@ProgrammerForever

Option 1 : store a variable - line number , write to the desired line, each time incrementing the variable
Option 2 : each time you open a file, count the number of lines in it, write to the last + 1 line

O
Oleg, 2020-06-22
@Oleg_F

Use the openpyxl library for this.
Through append, add new lines.
Example:

headers       = ['Company','Address','Tel','Web']
workbook_name = 'sample.xlsx'
wb = Workbook()
page = wb.active
page.append(headers)
wb.save(workbook_name)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question