CCCodes CCCodes - 2 years ago 192
Python Question

Openpyxl NotImplementedError Only When Loading Workbook

I have been working on a program to input some data into an excel file using Openpyxl with options of either loading an existing file or creating a new file. While creating a new file allows me to write the data to the excel file without any problems but loading from an existing file and trying to write new data to new rows raises a NotImplementedError with the line:

ws['A' + str(row)] = gene]

even though it was the same for writing to a new file.

Any help would be greatly appreciated!

Update: Thanks Charlie, after removing use_iterators from:
wb = load_workbook(filename=file_name+'.xlsx', use_iterators=True)
, the code let me write to the file.

Answer Source

If you open a file in read-only mode, why do you expect to be able to edit it? The exception is raised for exactly this reason.

Remove use_iterators when opening the file to avoid this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download