mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix issue that ints would be imported with a trailing ".0" from Google Sheets.
Summary: Whole numbers, when imported from Excel into a Text column show up without decimals (e.g. "300"), but when imported from Google Sheets show up with decimals (e.g. "300.0"). The decimals are hard for end-users to remove. Fix by treating whole numbers consistently as ints. Test Plan: Added a fixture reproducing the issue, and a test case. Reviewers: georgegevoian Reviewed By: georgegevoian Differential Revision: https://phab.getgrist.com/D3800
This commit is contained in:
@@ -195,6 +195,12 @@ class ColumnConverter(object):
|
||||
# For some reason, we get 'str' type rather than 'unicode' for empty strings.
|
||||
# Correct this, since all text should be unicode.
|
||||
value = u"" if value == "" else value
|
||||
|
||||
# Integer values sometimes show up as ints (from Excel), sometimes as floats (from Google).
|
||||
# Make them consistently ints; this avoid addition of ".0" suffix when converting to text.
|
||||
if type(value) == float and value.is_integer():
|
||||
value = int(value)
|
||||
|
||||
try:
|
||||
conv = self._converter.convert(value)
|
||||
self._converted_values.append(conv)
|
||||
|
||||
Reference in New Issue
Block a user