Can't manually escape cell values with '
See original GitHub issueI am exporting short git sha1 references, such as “1234”, “abcd”, “fe3a” etc, and whenever a sha1 reference happens to be something like “7e30” or “9e50”, the cells are filled with the corresponding number in scientific notation instead of the strings they are.
This stems from value_input_option='USER_ENTERED'
on https://github.com/robin900/gspread-dataframe/blob/9ea7aec5c44f13c65ff06ef6fee51f10c566ec78/gspread_dataframe.py#L254
Allowing one to override this option could be a workaround, or, one could expect to be able to prepend the relevant cell values with '
before export (just like one would as a user entering such values in the spreadsheet).
However, due to https://github.com/robin900/gspread-dataframe/blob/9ea7aec5c44f13c65ff06ef6fee51f10c566ec78/gspread_dataframe.py#L58-L59 any cell values that starts with '
gets another '
prepended, resulting in the literal value of '7e30
being saved in the cell rather than 7e30
.
Changing line 58 to if (not allow_formulas) and value.startswith('='):
resolves this issue, however one needs to remember to prepend '
to relevant cell values before every export.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
@motin I’ve created release 3.1.0 in PyPI with this feature. If you have any feedback on the feature that I need to incorporate into the code, I’d be glad to do so and make a further release.
I’ve changed the accepted values of
string_escaping
. Here’s the new parameter documentation. Your desired option would be'off'
.The branch/PR is updated with the new code to match the documentation above, with full test coverage. You’re welcome to test it and give commentary today. And because this new code is backwards compatible with prior releases, I am ready to cut a new release quickly and push to PyPI today.