Skip to main content

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.
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)
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