Skip to content

fix: trim whitespace from CSV headers during import#638

Open
chesta02 wants to merge 1 commit into
Kuldeeep18:mainfrom
chesta02:fix/lo-121-trim-csv-headers
Open

fix: trim whitespace from CSV headers during import#638
chesta02 wants to merge 1 commit into
Kuldeeep18:mainfrom
chesta02:fix/lo-121-trim-csv-headers

Conversation

@chesta02

@chesta02 chesta02 commented Jul 9, 2026

Copy link
Copy Markdown

🔗 Related Issue

Closes #558


📝 Summary of Changes

  • Trim leading and trailing whitespace from CSV headers before processing.
  • Preserve None header values to avoid errors.
  • Ensure headers like " Email " are correctly recognized during import.

👉 Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor
  • 📝 Documentation update
  • 🎨 UI / Style change
  • 🔧 Chore

🧪 Testing

  • Tested by reviewing the CSV import logic.
  • Verified that headers are stripped before processing.
  • Existing functionality remains unchanged for valid CSV files.

Summary by CodeRabbit

  • Bug Fixes
    • Improved CSV lead imports by handling extra whitespace in column headers more reliably, reducing mismatches when mapping fields.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fe026625-368a-4f6a-87ac-89433cc19baf

📥 Commits

Reviewing files that changed from the base of the PR and between 4a33158 and 446ae1e.

📒 Files selected for processing (1)
  • backend/leads/tasks.py

📝 Walkthrough

Walkthrough

The import_leads_from_csv task now strips leading and trailing whitespace from CSV header names before using them for field mapping, preserving None entries in the fieldnames list.

Changes

CSV Header Trimming

Layer / File(s) Summary
Strip whitespace from CSV headers
backend/leads/tasks.py
After CSV dialect detection, header names in reader.fieldnames are trimmed of leading/trailing whitespace (preserving None entries) before being used for field mapping.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the main change: trimming whitespace from CSV headers during import.
Linked Issues check ✅ Passed The change strips whitespace from CSV header names before downstream matching, matching issue #558's import sanitization requirement.
Out of Scope Changes check ✅ Passed The only described change is header trimming in backend/leads/tasks.py, with no unrelated or extra scope visible.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Warning

⚠️ This pull request shows signs of AI-generated slop (redundant_comments). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LO-121 [Easy]: Trim Whitespace from Custom CSV Headers during Import

1 participant