I want to go into my current folder and edit whatever files is in the folder with the string "test" onto cell 0,0 and then save it as book1.xlsx but my code is giving me an error. Can anyone help?
import xlrd
import os
import glob
from xlutils.copy import copy
fileDir = os.getcwd()
fileLocation = glob.glob("*.xlsx")
x = copy(fileLocation)
x.get_sheet(0).write(0,0,"test")
x.save('book1.xlsx')
glob.glob("*.xlsx") must return a list, so I think the error is on the copy statement.
Try with :
x = copy(fileLocation[0])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.