← All guides

Piwi field notes · 2 min read

Validate a CSV before it reaches your CRM

Use Piwi's local CSV tool to catch malformed rows, preserve source data, and prepare a reviewed import.

Define the accepted record

Start with a concrete input: a comma-delimited export with unique, non-empty headers. Keep the original export unchanged and decide which fields your CRM requires. CSV parsing verifies structure; it does not establish that an email address belongs to a person or that a contact consented to messages.

Connect the local tools

Follow Piwi's connection guide to build the Docker images and add the local MCP server to your client. Ask the agent to call piwi_run_csv_clean with input containing a csv string and trim set to true only when leading and trailing whitespace should be removed. A request can contain at most 100000 UTF-16 code units in the CSV field, subject to the 256 KiB JSON request limit.

Inspect the results before continuing

For CSV containing headers name,email, a valid Ada row, and a third row with just one field, the tool returns the Ada record in rows and an error for row 3 with expected: 2 and actual: 1. Treat that error as a reason to correct the source or explicitly exclude the record. Never silently use only the accepted rows and assume the import is complete.

Quoted commas and embedded newlines are preserved. Error row numbers count CSV records, including the header; they are not physical line numbers for multiline fields. Formula-like values remain plain strings in JSON. Review spreadsheet formula handling separately before exporting into a spreadsheet.

Make each next step explicit

The accepted rows are structured JSON. Your agent can use json.select to extract selected fields, or list.unique to deduplicate an array of exact string values. These are separate tool calls made by your agent. Piwi does not automatically import the result into a CRM or merge records.

For a small export, file.metadata can produce a SHA-256 checksum of the original supplied content. Save the checksum with your review notes if you need to identify which export was processed. The tool accepts up to 128 KiB of decoded content.

Decide what should stay manual

Stop for conflicting customer records, missing consent information, ambiguous column meanings, or an export beyond the supported limits. A person should decide the correction policy. Once the source is accepted, use the CRM's own reviewed import procedure. Measure success by accepted records and corrections avoided, not merely by how many rows an agent processed.