I've been working w/ OpenpyXL to organize data in Excel workbooks. I have a dataset where on the first sheet 'Data' is about 70 columns & 400 rows of numerical data. A custom function I have goes into another sheet 'Average' and averages across the columns such that theres 1 col & 400 rows of data.
Then, this information is copied to another workbook.
but there's a weird bug. My custom function that copies data reports theres no data in the 'average' sheet. Inspecting the workbook with the "preview" pane in Windows explorer, I see there is indeed no data in column 'A' where data should be averaged.
But when I open the spreadsheet, the averages are all there. If I close the spreadsheet and look at the preview, there's nothing there. If I open the spreadsheet again and edit it in any way close it, and I check the preview, there's data there.
Edit: And when I say that there's "no" data picked up by pthon: What I mean is, is that if I set the load_workbook flag "data_only" to "true", such that I should get only call values and not the formula, python prints out "none" line by line. But if I remove that "data_only" argument completly, I get the formula line by line, which is the "=average(A1:BR1)" or whatever. And then this copies successfully to the new workbook.
So I feel like the preview is telling. I tried adding the workbook.close() function after saving, so that the workbook is saved, closed properly, then re-opened. Didn't work.
I also tried brute forcing the "Editing" I was doing by hand by opening the workbook, entering some arbitrary value in a random cell, then saving & closing it. Didn't work.
Edit2: Seems to be related to this stackoverflow: Python openpyxl data_only=True returning None