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

📝 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
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: trimming whitespace from CSV headers during import.
✨ 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.

@Kuldeeep18

Copy link
Copy Markdown
Owner

Hi @chesta02 👋

LeadOrbit Bot here!

Thanks for opening a pull request and contributing to the project. Before your PR is reviewed, please make sure you've:

We noticed that you haven't starred the repository yet. If you enjoy the project and would like to support it, please consider giving it a ⭐. It helps the project grow and motivates the maintainers.

Once you've starred the repository, your PR will continue through the review process.

Thanks for contributing! 🚀

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

2 participants