Patterns
intermediatedata processing Featured

CSV/Excel Import Validator

Accept file uploads (CSV, Excel), validate every row against business rules, report errors to the submitter, and import clean data into the target system. The essential pattern for bulk data intake.

Views15
BPMN 2.0
On this page

Visual Flow

Rendering diagram…

When to Use This Pattern

Use CSV/Excel import when:

  • Business users need to bulk import data (products, contacts, prices, inventory)
  • Manual data entry is error-prone and time-consuming
  • The imported data must meet quality standards before entering the system
  • You need to provide feedback to the submitter about which rows passed and which failed

How It Works

StageActionOutput
1. UploadUser uploads CSV/Excel fileRaw file
2. ParseRead file, extract headers and rowsStructured data array
3. ValidateCheck each row against business rulesValid rows + error report
4. ReviewUser reviews errors, decides to proceed or fixDecision
5. ImportInsert/update valid rows into target systemImported records
6. ReportGenerate summary with import resultsSuccess/failure counts

Implementation Guide

Step 1: Build the Upload Form

Create a form with:

  • File upload field — accept .csv, .xlsx, .xls only
  • Import type selector — "Contacts", "Products", "Prices" (determines validation rules)
  • Update strategy — "Create new only", "Update existing only", "Create + update"
  • Preview/dry run option — validate first without importing
Step 2: Parse the File
File TypeParsing Method
CSVSplit by delimiter (comma, semicolon, tab)
Excel (.xlsx)Use Read Excel action or library
Excel (.xls)Convert to xlsx first, then parse

Handle parsing edge cases:

  • Detect the delimiter automatically (some regions use semicolons)
  • Handle quoted fields that contain the delimiter
  • Detect and handle different encodings (UTF-8, Latin-1)
  • Skip empty rows and header rows
  • Trim whitespace from all cell values
Step 3: Validate Each Row

Run validation rules per column:

ColumnRuleError Message
EmailValid email format"Row 5: Invalid email format"
PhoneValid phone number"Row 12: Phone number too short"
AmountNumeric, > 0"Row 8: Amount must be a positive number"
DateValid date, not in future"Row 3: Date cannot be in the future"
CategoryMust be in allowed list"Row 15: 'Widgetz' is not a valid category. Did you mean 'Widgets'?"
Required fieldsNot empty"Row 22: Name is required"
Unique constraintNo duplicates in file or system"Row 7: Email already exists in the system"
Step 4: Generate the Error Report

Produce a clear, actionable error report:

📋 Import Validation Results
━━━━━━━━━━━━━━━━━━━━━━━━━━━

File: contacts_march_2025.xlsx
Total rows: 150
Valid: 142 (94.7%)
Errors: 8 (5.3%)

❌ Row 5: Email "john.doe@" — Invalid email format
❌ Row 12: Phone "+1555" — Phone number too short (minimum 10 digits)
❌ Row 18: Amount "-50" — Amount must be a positive number
❌ Row 23: Email "jane@company.com" — Duplicate: already exists in system
❌ Row 45: Category "Widgetz" — Not a valid category. Did you mean "Widgets"?
❌ Row 67: Name "" — Name is required
❌ Row 89: Date "2026-01-01" — Date cannot be in the future
❌ Row 134: Email "bob@acme.com" — Duplicate: same email on row 56

🔄 Options:
[Import 142 valid rows] [Download error report] [Fix and re-upload]
Step 5: Import Valid Rows

For each valid row:

  1. Check if record exists (by unique key — email, SKU, etc.)
  2. Create new or update existing based on the chosen strategy
  3. Log each operation (created/updated/skipped)
  4. Handle API rate limits — if importing to a cloud system, respect its rate limits
Step 6: Post-Import Summary
MetricCount
Rows in file150
Rows validated150
Rows with errors8
New records created120
Existing records updated22
Skipped (no changes)0
Import time45 seconds

Tips & Best Practices

Tip

Always offer a template download. Give users a pre-formatted Excel file with headers, sample data, and data validation dropdowns. This prevents 80% of import errors.

  • Show a preview. Before importing, show the first 5 rows so the user can confirm the columns mapped correctly.
  • Handle duplicates gracefully. Don't just reject duplicates — offer options: skip, update, or flag for review.
  • Provide a downloadable error report. For files with many errors, an on-screen list isn't enough. Let users download a CSV of just the failed rows (with error message in an extra column) so they can fix and re-upload.
  • Support incremental imports. Large files (10,000+ rows) should be processed in chunks. Show progress and allow cancellation.

Related patterns