File De-identification
Pass a file, get a de-identified file back.
Python
from custodian_labs import GuardianLayer
result = GuardianLayer().deidentify_file("./customers.csv", masking_type="transform")
with open(result.filename or "deid_customers.csv", "wb") as f:
f.write(result.content)
TypeScript
import { writeFile } from "node:fs/promises";
import { GuardianLayer } from "@custodianlabs/sdk";
const result = await new GuardianLayer().deidentifyFile("./customers.csv", { maskingType: "transform" });
await writeFile(result.filename ?? "deid_customers.csv", result.content);
deidentify_file / deidentifyFile dispatches by extension. Explicit
deidentify_csv / deidentify_docx / deidentify_pdf / deidentify_txt methods
exist too.
Supported types
| Extensions | Notes |
|---|---|
.csv, .xlsx, .xls | Returned in the same format |
.docx | .doc not accepted — convert first |
.pdf | Needs extractable text (scanned images → coming soon) |
.txt |
masking_type (transform / redact) and pii_entities work the same as for text.
See also
Guardian Layer client (Python) · (TypeScript) · Guide: De-identify CSV · De-identify PDF