-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transfer Excel data I/O to ixmp #321
Conversation
d75df63
to
dd03ad0
Compare
Codecov Report
@@ Coverage Diff @@
## master #321 +/- ##
==========================================
+ Coverage 88.06% 88.63% +0.56%
==========================================
Files 29 29
Lines 2581 2543 -38
==========================================
- Hits 2273 2254 -19
+ Misses 308 289 -19
Continue to review full report at Codecov.
|
2c5e8d7
to
cfef44e
Compare
Thanks a lot @khaeru for cleaning up here and moving this to ixmp.
3- I personally think having variables written in Excel is not needed while it can be useful sometimes, especially for small scenarios. Because for scenarios with large data, there is already a memory burden in writing all data in Excel. I assume with many variables added to this, it becomes more difficult.
c. Any feedback welcome for No. 3 and 5 above. |
Thanks for these detailed comments, and for catching the issue with
As @zikolach pointed out (see iiasa/ixmp#292 (comment)), we can imagine multiple ways to change the format. But I don't think that's very urgent and—as I commented on that issue—people have existing Excel files sitting around that they will want to continue to use. So I would like to minimize disruption. Here's what I'd propose. All these changes will go in ixmp:
Some other reactions:
|
…ed hard coded number (#2)
for engine in 'openpyxl', 'xlsxwriter':
xw = pd.ExcelWriter(f'{engine}.xlsx', engine=engine)
df = pd.DataFrame()
df.to_excel(xw, sheet_name='foo')
df.to_excel(xw, sheet_name='FOO')
xw.close() What I observe:
So this is likely a limitation of the Excel format per se, and openpyxl contains a workaround that would, in any case, defeat our code. |
In order to keep moving, I went ahead and implemented the suggestion in the above comment as iiasa/ixmp#297. @behnam-zakeri @Jihoon can either of you confirm that the combination of these two branches works as desired? |
As with iiasa/ixmp#297, will merge this without review in order to clear the ground for hackathon PRs. If needed, we can make another to adjust, later. |
Thanks @khaeru for taking this forward. The solutions you suggested are excellent, for making sets and parameters default data to be written, and for ordering the sheets. And interesting test for Excel engine you illustrated.
I meant memory burden for writing many rather large parameters to multiple Excel sheets, and not particularly exceeding row limits. |
iiasa/ixmp#292 is the follow-up issue for modifying the Excel file format to extend past the ~10⁶ row limit. It would be great if you wanted to tackle this, but no pressure. If so, please create an ixmp (here is message_ix) branch named e.g. Also note that @volker-krey supplied example code in iiasa/ixmp#300 that addresses the same limitation by establishing a new, zipped-CSV format, which might be rolled into the same PR. |
Thanks @khaeru for the instructions. I'll follow this on ixmp. |
This PR removes the
message_ix.Scenario.to_excel()
and.read_excel()
methods.iiasa/ixmp#286iiasa/ixmp#289 adds these toixmp.Scenario
, so they are available for non-MESSAGE scenarios.It also incorporates test improvements from #265.
How to review
Wait for Transfer Excel data I/O from message_ix ixmp#289 to merge, or check out its branch.PR checklist