Skip to main content

Importing Data

Import data from CSV or XLSX files into MongoDB collections using NetPad's import wizard.

Starting an Importโ€‹

  1. Navigate to Data Import:

    • Go to Data Explorer
    • Click "Import Data" button
    • Or go to /data/import
  2. Select File:

    • Click "Choose File"
    • Select CSV or XLSX file
    • File uploads to NetPad

Import Wizard Stepsโ€‹

Step 1: Upload Fileโ€‹

  • Select File: Choose CSV or XLSX
  • File Size Limit: Check file size limits
  • Supported Formats: CSV, XLSX
  • Upload: File uploads automatically

Step 2: Analyze Fileโ€‹

NetPad analyzes your file:

  • Detects Columns: Identifies all columns
  • Detects Types: Infers data types
  • Shows Preview: Displays sample rows
  • Identifies Issues: Flags potential problems

Step 3: Map Columnsโ€‹

Map file columns to MongoDB fields:

  1. View Columns:

    • See all file columns
    • See detected types
    • See sample values
  2. Map to Fields:

    • Select target field for each column
    • Create new fields if needed
    • Skip columns you don't need
  3. Configure Mapping:

    • Field names
    • Data types
    • Default values
    • Transformations

Step 4: Configure Importโ€‹

Set import options:

  • Target Collection: Select or create collection
  • Import Mode:
    • Insert: Add new documents
    • Update: Update existing documents
    • Upsert: Insert or update
  • Duplicate Handling: Skip or update duplicates
  • Batch Size: Documents per batch

Step 5: Previewโ€‹

Review mapped data:

  • Preview Rows: See how data will look
  • Verify Mapping: Check field mappings
  • Check Types: Verify data types
  • Identify Issues: Fix any problems

Step 6: Execute Importโ€‹

Run the import:

  1. Click "Import": Start import process
  2. Monitor Progress: Watch import progress
  3. View Results: See import summary
  4. Review Errors: Check any errors

Column Mappingโ€‹

Automatic Mappingโ€‹

NetPad tries to map columns automatically:

  • Name Matching: Matches column names to field names
  • Type Matching: Matches data types
  • Smart Detection: Infers relationships

Manual Mappingโ€‹

Manually map columns:

  1. Select Column: Click column
  2. Choose Field: Select target field
  3. Configure: Set mapping options
  4. Transform: Apply transformations if needed

Field Creationโ€‹

Create new fields during import:

  1. Click "New Field": For unmapped column
  2. Set Field Name: Enter field name
  3. Set Type: Choose data type
  4. Configure: Set field options

Data Transformationsโ€‹

Type Conversionsโ€‹

Convert data types:

  • String to Number: Parse numbers
  • String to Date: Parse dates
  • Format Dates: Standardize date formats
  • Trim Whitespace: Clean strings

Value Transformationsโ€‹

Transform values:

  • Uppercase/Lowercase: Change case
  • Replace Text: Find and replace
  • Concatenate: Combine columns
  • Split: Divide into multiple fields

Default Valuesโ€‹

Set defaults for missing values:

  • Empty Cells: Fill with default
  • Null Values: Replace nulls
  • Missing Fields: Add default values

Import Modesโ€‹

Insert Modeโ€‹

Add new documents:

  • New Documents: Creates new documents
  • No Updates: Doesn't modify existing
  • Use When: Importing new data

Update Modeโ€‹

Update existing documents:

  • Matches Existing: Finds matching documents
  • Updates Fields: Modifies existing documents
  • Use When: Updating existing data

Matching Criteria:

  • Match by _id
  • Match by unique field
  • Match by multiple fields

Upsert Modeโ€‹

Insert or update:

  • Insert New: Creates new documents
  • Update Existing: Modifies existing
  • Use When: Mixed new and existing data

Handling Duplicatesโ€‹

Skip Duplicatesโ€‹

Ignore duplicate entries:

  • Detect Duplicates: Based on matching criteria
  • Skip: Don't import duplicates
  • Report: Show skipped count

Update Duplicatesโ€‹

Update existing duplicates:

  • Find Duplicates: Match criteria
  • Update: Modify existing documents
  • Merge: Combine data

Duplicate Criteriaโ€‹

Define what counts as duplicate:

  • By ID: Match _id field
  • By Field: Match specific field
  • By Multiple Fields: Match combination

Import Progressโ€‹

Monitoringโ€‹

Watch import progress:

  • Progress Bar: Shows completion percentage
  • Documents Processed: Count of processed documents
  • Errors: Number of errors
  • Time Remaining: Estimated time

Resultsโ€‹

View import results:

  • Total Documents: Number imported
  • Successful: Successfully imported
  • Failed: Failed imports
  • Errors: Error details

Error Handlingโ€‹

Common Errorsโ€‹

Invalid Data Types:

  • Fix: Adjust type mapping
  • Solution: Transform data

Missing Required Fields:

  • Fix: Map required fields
  • Solution: Set default values

Duplicate Keys:

  • Fix: Adjust duplicate handling
  • Solution: Update instead of insert

File Format Issues:

  • Fix: Check file format
  • Solution: Re-export file

Error Reportsโ€‹

View detailed errors:

  • Error Messages: What went wrong
  • Row Numbers: Which rows failed
  • Field Names: Which fields had issues
  • Fix Suggestions: How to fix

Best Practicesโ€‹

  1. Prepare Data: Clean data before import
  2. Test First: Import small sample first
  3. Backup: Backup collection before import
  4. Verify Mapping: Check all mappings
  5. Monitor Progress: Watch for errors
  6. Review Results: Verify imported data

File Format Requirementsโ€‹

CSV Filesโ€‹

  • Encoding: UTF-8 recommended
  • Delimiter: Comma (configurable)
  • Headers: First row should be headers
  • Quotes: Use quotes for fields with commas

XLSX Filesโ€‹

  • Format: Excel 2007+ format
  • Sheets: First sheet used by default
  • Headers: First row should be headers
  • Data Types: Preserved from Excel

Next Stepsโ€‹