0

enter image description here

I want to add new records every week to this existing file without creating a new one.

For example, Next I want to add record on date 6/13/2016

Randy->(13,23,13)

Shaw->(13,15,13)

and many such entries next two months. How do I do that? I am beginner so having trouble to put it in syntax.

I could do only this much

import xlrd

#Opening the excel file
file_location= "C:/Users/agodgh1a/Desktop/Apurva/EPSON.xlsx"
workbook= xlrd.open_workbook(file_location)
sheet=workbook.sheet_by_index(0)

Thank you!

2 Answers 2

2

The lib you're using looks like it only reads, not edits. Here's an example in openpyxl:

from openpyxl import Workbook, load_workbook

# create the file
wb = Workbook()
ws = wb.active
ws.append([1, 2, 3])
wb.save("sample.xlsx")

# re-open and append
wb = load_workbook("sample.xlsx")
ws = wb.active
ws.append([4, 5, 6])
wb.save("sample.xlsx")

Run that and you'll have a file sample.xlsx with both rows.

Sign up to request clarification or add additional context in comments.

Comments

1
xlrd 

is for reading operations only. Since you want perform a write operation use xlwt python module.

Refer to xlwt docs for the same

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.