De-identify a CSV or Excel file
Send a spreadsheet and get the same spreadsheet back with personal data replaced. It
works with .csv, .xlsx and .xls files. The output is in the same format as the
input.
customers.csv
name,email,phone,notes
Jane Smith,jane.smith@example.com,(415) 555-0123,Requested a follow-up call.
Alex Chen,alex.chen@example.com,(212) 555-0198,Interested in enterprise support.
- Python
- TypeScript
- curl
from custodian_labs import GuardianLayer
guardian = GuardianLayer()
# CSV
result = guardian.deidentify_file("customers.csv", masking_type="transform")
with open(result.filename or "deid_customers.csv", "wb") as f:
f.write(result.content)
# Excel: same call, same format back
result = guardian.deidentify_file("customers.xlsx", masking_type="redact")
with open(result.filename or "deid_customers.xlsx", "wb") as f:
f.write(result.content)
import { writeFile } from "node:fs/promises";
import { GuardianLayer } from "@custodianlabs/sdk";
const guardian = new GuardianLayer();
// CSV
let result = await guardian.deidentifyFile("customers.csv", { maskingType: "transform" });
await writeFile(result.filename ?? "deid_customers.csv", result.content);
// Excel: same call, same format back
result = await guardian.deidentifyFile("customers.xlsx", { maskingType: "redact" });
await writeFile(result.filename ?? "deid_customers.xlsx", result.content);
curl -X POST "https://privacy.custodianlabs.io/api/v1/deidentify/text/proprietary/outputs/csv" \
-H "X-API-Key: $CUSTODIAN_API_KEY" \
-F "file=@customers.xlsx" \
-F "masking_type=transform" \
-o deid_customers.xlsx
The same endpoint takes .csv, .xlsx and .xls files.
Prefer no code? Use the Dashboard
CSV files also work in the Dashboard. Open API Testing, choose Upload File, pick the mode and the types of data, then click Mask Now. Excel files need the SDK or API for now.
How spreadsheets are handled
- Every sheet in an Excel workbook is processed.
- The first row is treated as column headers and kept as it is. The column names help Guardian Layer recognise what each column holds, such as names, emails or phone numbers.
- The output keeps the layout: the same columns, rows and sheets, and the same file type.
To limit what's changed, pass pii_entities, such as ["PERSON", "EMAIL_ADDRESS"]. See
Supported entities. For other output styles, set
masking_type to redact or placeholder.
See also
File de-identification · De-identify a Word document · Guardian Layer API: files