-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
Append Mode for ExcelWriter with openpyxl #21251
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm maybe do for 0.24.0
@@ -804,6 +804,8 @@ class ExcelWriter(object): | |||
datetime_format : string, default None | |||
Format string for datetime objects written into Excel files | |||
(e.g. 'YYYY-MM-DD HH:MM:SS') | |||
mode : {'w' or 'a'}, default 'w' | |||
File mode to use (write or append). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a versionadded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's worth adding this class to the API? Would be a little strange as its an ABCMeta but on the flip side may still be beneficial for those looking further at it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's worth adding this class to the API?
Can't you just do from pandas.io.excel import ExcelWriter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the import mechanism I was referring to as much as the documentation - this class is not part of the doc build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pandas/io/excel.py
Outdated
try: | ||
self.book.remove(self.book.worksheets[0]) | ||
except AttributeError: | ||
# Openpyxl 1.6.1 adds a dummy sheet. We remove it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can remove this comment (and maybe don't need this anymore), 1.6.1 is lower than supported version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless I'm overlooking it I don't see an explicit min version. Happy to add one - what would that be?
Codecov Report
@@ Coverage Diff @@
## master #21251 +/- ##
==========================================
+ Coverage 91.84% 91.85% +<.01%
==========================================
Files 153 153
Lines 49538 49546 +8
==========================================
+ Hits 45499 45509 +10
+ Misses 4039 4037 -2
Continue to review full report at Codecov.
|
thanks @WillAyd |
I am not sure if I am supposed to be posting issues on this board so please let me know if I should be posting elsewhere. I have tried utilizing |
@enterdisplaynamehere this feature is being released as part of 0.24 which we just issued a release candidate for over the past few days. You can try on the RC or here on master and if neither works open an issue per the contributing guide, but this wouldn't be expected to work on versions older than that |
@WillAyd Ok, got it, thanks. It's the first time I've ever heard of 'RC'. I just downloaded it and gave it a shot. It seems to work for an existing workbook but not for a workbook that doesn't exist. I am assuming a workbook should be created per |
Hi, How come when looking at ExcelWriter documentation on But when I try using the same syntax I receive this error I tried using engine='openpyxl' but it is very slow and sometimes causes the file to become corrupted and not being able to open. Any feedback is appreciated. Thanks. |
@yehia123 this was only implemented for openpyxl and I'm not sure it's even possible to append with xlsxwriter. If you research and find otherwise certainly can open as an enhancement request on the issue tracker |
@WillAyd Thank you for the quick response. I ended up making my file csv instead of xlsx and used to_csv(); the append mode is much faster than 'openpyxl'. |
git diff upstream/master -u -- "*.py" | flake8 --diff