Warp

Import a messy customer CSV into Filament, and fix it before anything is saved

5 min read

You are moving a company off its old customer system. The old system can export a CSV, and that is all it can do. The headers are its own ("Client ID", "Mail", "Mobile", "Membership level"), and years of hand-typed data have left a few surprises: an email without an @, a customer with no name, the same customer exported twice.

Filament's import action can read the file. But you choose the columns in a list, press Import, and find out about the bad rows afterwards, in a CSV of failed rows. Then you fix that file and import again, hoping you did not create half of the customers twice.

This article shows the same move with Warp Import: every row is checked before anything is written, the problems are shown next to the rows, and you fix the cells right there. All pictures are from the live demo.

The scene: the export from the old system

This is the file. Five customers, six columns, and three rows with problems.

A CSV opened as a spreadsheet with the columns Client ID, Full name, Mail, Mobile, Nation and Membership level, and five customers
old-system-customers.csv. Row 3 has no @ in the email, row 4 has no name, and row 5 is row 2 again.

Step 1: swap the import action

The importer is a normal Filament importer. Keep it as it is. On the list page, use WarpImportAction in place of Filament's ImportAction:

use Qalainau\FilamentWarpImport\Actions\WarpImportAction;

protected function getHeaderActions(): array
{
    return [
        WarpImportAction::make()
            ->importer(CustomerImporter::class)
            ->aiSuggestions(),
    ];
}

The importer's columns and rules decide what a valid row is, exactly as in Filament:

public static function getColumns(): array
{
    return [
        ImportColumn::make('code')->requiredMapping()
            ->rules(['required', 'max:16'])->guess(['code', 'customer code']),
        ImportColumn::make('name')->requiredMappingForNewRecordsOnly()
            ->rules(['required', 'max:255'])->guess(['name']),
        ImportColumn::make('email')
            ->rules(['nullable', 'email', 'max:255'])->guess(['email', 'e-mail']),
        // phone, country and rank in the same way
    ];
}

public function resolveRecord(): Customer
{
    return Customer::firstOrNew(['code' => $this->data['code']]);
}

Step 2: match the columns

Press "Import customers" and drop the file in. The wizard has four steps: File, Columns, Review, Import. "Full name" is matched to Name by itself. "Client ID", "Mail" and "Mobile" mean nothing to it, so Code, Email and Phone stay on "Do not import", and Code is marked as required.

The Columns step of the import: Name is matched to Full name, Code, Email and Phone are still Do not import, and Code is marked as required
The old system's headers do not match your field names.

You can pick each header from the list. Or press "Suggest with AI": Claude gets the fields that are not matched yet and the unused headers, with up to three values from each, and fills in the gaps. Each answer gets an "AI" badge until you change it.

After Suggest with AI, Code is matched to Client ID, Email to Mail and Phone to Mobile, each with an AI badge
Client ID → Code, Mail → Email, Mobile → Phone. Check them, then go on.

Nothing is imported on the AI's word. Its answers only fill fields that are still "Do not import", and every row still goes through the review below. (The demo has no API key, so a small fixed list answers in place of Claude.)

Step 3: see every problem before importing

"Check 5 rows" runs each row through your importer as Filament would (resolveRecord(), the rules, fillRecord()) and stops right before saveRecord(). It all happens in a transaction that is rolled back, so nothing is written yet.

The Review step: cards for All 5, New 2, Errors 2 and Duplicates 1, a row with an invalid email in red, a row with a missing name in red, and a row marked Duplicate: Same record as row 2
Two errors and one duplicate, each with its reason. The button says "Import 2 rows".
  • Error: a rule failed. The message is Laravel's, and the cell is marked.
  • Duplicate: an earlier row points at the same record. Only the first one is imported, so the customer is not created twice.
  • Changed records (when a customer is already in your app) show the old value struck through next to the new one.

Numbers, dates and yes/no values are checked before your rules, too. Filament reads abc in a number column as 0. Warp Import reports it as an error.

Step 4: fix the cells, then import

Double-click a red cell, type the right value, and press Enter. The row is checked again at once.

Two cells fixed in the review, then "Import 4 rows".
The Review step after the fixes: New 4, Errors 0, Duplicates 1, and the button reads Import 4 rows
No errors left. The duplicate stays out.

The import writes the rows with your importer, the same steps as Filament, hooks included. A row that fails while writing is rolled back on its own and listed. The others are written.

The result: Created 4, Not imported 1 with the reason it is the same record as row 2, and an Undo this import button
Four customers created. The duplicate is listed as not imported, with the reason.

If something still looks wrong, "Undo this import" deletes what the import created and writes back the old values of what it changed, for 30 days by default. A record someone edited after the import is left alone.

Next month's file

When the same export arrives again, "Save as template…" in the review keeps the column matching and the clean-up, so the next file with the same headers needs no matching at all. Files that arrive on a schedule can be imported by themselves.

Other scenes

  • Supplier price lists in Excel, with prices like $1,200 and headers that change every season.
  • Switching CRM or accounting tools: customers and their orders, with orders and lines on separate sheets in one file.
  • Files from other countries: other separators, decimal commas and Shift_JIS encoded CSVs from Japanese Excel.
  • Records missing from the file: find customers that are in your app but no longer in the export.

Limits worth knowing

  • .xls (Excel 97–2003) is not supported. Save as .xlsx or CSV. Excel formulas come in as their last calculated values.
  • Undo does not detach records attached with belongsToMany, and does not undo side effects of your hooks (mail, API calls).
  • Hooks that act outside the database also run while checking. Keep mail and API calls in afterSave(), which does not run during the review.
  • With aiSuggestions(), headers and up to three sample values per column are sent to Anthropic when the user presses the button, never on their own. Turn samples off, or leave the feature off, for data that must not leave your servers.

Try it

Open the customers page in the demo and press "Import customers". "Sample file" gives you a CSV to start with. Break a few cells in it before you import, and fix them in the review. No sign-up, and the data is reset every hour.

More from the blog

Stop duplicate customers in a Filament form before they are saved

The same customer added twice, once with capitals in the email and once with brackets in the phone number. Warn the person typing, show the existing customer, and keep your list clean.

Dispatch field technicians from a Filament schedule board

Morning at a repair company. Drag each waiting job from a Filament table onto a technician's row, let the board refuse double bookings, and stretch a job when it runs long.

Paste an Excel order into a Filament repeater

A customer sends 120 order lines in a spreadsheet. Let your team paste them straight into a Filament repeater, with products picked, totals recalculated and nothing retyped.

Filament + AI coding tips, by email

How to fit Warp plugins into your own app and pair them with Claude Code or Cursor: prompts that work, mistakes AI makes, real examples. Once or twice a month. Unsubscribe anytime.

Ask us anything about Warp

No email address or sign-up needed.

We read every question and answer here on the site, usually within a day. Others see your question after we have checked it.

What's stopping you from using Warp's plugins?

One question. We read every answer, and it decides what we build next. It is not shown on the site.

What's stopping you from using Warp's plugins?