fix: round integer values during Excel and CSV import - #1381
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Non-finite CSV values may be silently imported as NULL instead of being rejected.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Updates Excel/CSV imports to round explicitly selected integer values using ROUND_HALF_UP, preserve nulls, and validate inputs.
Changes:
- Added validated integer rounding and range checks.
- Centralized Excel/CSV import loading.
- Updated datasource integration.
File summaries
| File | Description |
|---|---|
backend/apps/datasource/utils/excel.py |
Implements validated integer rounding during imports. |
backend/apps/datasource/api/datasource.py |
Uses the shared import dataframe loader. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+32
to
+33
| if pd.isna(value) or (isinstance(value, str) and not value.strip()): | ||
| return pd.NA |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1365.
When an Excel or CSV column is explicitly imported as an integer, decimal values were truncated (for example, 1186.6071672 became 1186). Round these values using ROUND_HALF_UP so the example imports as 1187, preserve missing values with nullable integers, and reject invalid, non-finite, or out-of-range values. Other selected column types retain their existing behavior.
Validation: 31 local regression tests passed, covering Excel formula cached values, CSV input, rounding, nulls, precision, and signed 64-bit boundaries. The regression tests and workbook fixture remain local and are not included in this PR, as requested. Only the two datasource implementation files are included.