In a spreadsheet or CSV export, a column has a meaning. Everything in Member SSN is a Social Security number, nothing in Claim ID is personal, and only Notes holds free text. Detection that treats every cell the same ignores that. It can miss a partial value such as 987-65 in the SSN column, and it scans columns that need no scanning.
Column rules put that knowledge in the policy. A rule replaces every value in a column with no detection, leaves a column unchanged, or scans it with only the filters that suit it. This guide writes them in PhiSQL, compiles them, and applies them to a CSV file and an Excel workbook. For the basics of the language, see Authoring redaction policies with PhiSQL.
Note: As of December 1, 2026, the PhiSQL compilers (Python 1.6.0, Java 1.7.0, .NET 1.6.0) compile column rules, but no released Philter or Phileas applies them. Phileas 4.5.0 and Philter 4.0.1 do not read CSV or Excel files: Philter 4.0.1 refuses
text/csvwith415. Support is in Phileas’s main branch, published as4.6.0-SNAPSHOT, which is what the output below comes from, and in Philter’s main branch. Philter 4.0.1 still accepts a policy with column rules: it stores the JSON, ignores the rules, and applies the policy’s identifiers to text. The PhiSQL catalog says a runtime without column rules should reject such a policy instead, so do not take its acceptance as support.
The policy
claims-export.phisql covers a semicolon-separated claims export and a workbook with a Members worksheet:
POLICY claims_export;
REDACT EMAIL_ADDRESS, PHONE_NUMBER WITH REDACT;
CONFIGURE CSV (delimiter = ';');
CONFIGURE TABULAR SHEET (
headerRows = 1,
unlistedColumns = 'identifiers',
columns = [
(header = 'Member', action = 'redact', strategies = [(strategy = 'REDACT')]),
(header = 'Member SSN', action = 'redact', strategies = [(strategy = 'MASK')]),
(header = 'Claim ID', action = 'ignore'),
(header = 'Notes', action = 'filter', filters = ['emailAddress'])
]
);
CONFIGURE TABULAR SHEET (
worksheet = 'Members',
unlistedColumns = 'redact',
columns = [
(header = 'Member ID', action = 'ignore'),
(header = 'Plan', action = 'ignore')
]
);
CONFIGURE CSV sets how a CSV file is read: delimiter (default ,), quote (default "), and encoding (default UTF-8). It has no effect on Excel workbooks.
Each CONFIGURE TABULAR SHEET statement adds one sheet entry:
worksheetnames the worksheet the entry applies to, compared without regard to case. An entry without one applies to every worksheet that has no entry of its own, and to a CSV file.headerRowsis the number of header rows,1by default. Header rows are never redacted. Rules match theirheaderagainst the last header row. With0, columns can only be picked byindex, counting from 1.unlistedColumnsdecides what happens to columns without a rule.identifiers, the default, scans them with every filter in the policy.ignoreleaves them unchanged.redactreplaces every value withunlistedStrategies(oneREDACTby default), which makes the entry an allow-list: only columns with a rule survive.- Each rule in
columnspicks a column byheaderorindexand has anaction:redactreplaces every value withstrategies, with no detection.ignoreleaves the column unchanged.filterscans each cell with only thefiltersnamed, by their key in the compiledidentifiers(emailAddress, notEMAIL_ADDRESS).
When a header rule and an index rule pick the same column, the more protective one applies: redact, then filter, then ignore. The keywords CSV, TABULAR, and SHEET are not reserved, so they remain usable as names elsewhere.
Compile it
Compile with any of the reference compilers. All three produce the same policy, with different JSON formatting. With the Python one:
pip install phisql==1.6.0
phisql claims-export.phisql > claims-export.json
The rules compile to a top-level tabular section beside identifiers, and the CSV settings to config.csv:
{
"identifiers": {
"emailAddress": { "emailAddressFilterStrategies": [ { "strategy": "REDACT" } ] },
"phoneNumber": { "phoneNumberFilterStrategies": [ { "strategy": "REDACT" } ] }
},
"config": {
"csv": { "delimiter": ";" }
},
"tabular": {
"sheets": [
{
"headerRows": 1,
"unlistedColumns": "identifiers",
"columns": [
{ "header": "Member", "action": "redact", "strategies": [ { "strategy": "REDACT" } ] },
{ "header": "Member SSN", "action": "redact", "strategies": [ { "strategy": "MASK" } ] },
{ "header": "Claim ID", "action": "ignore" },
{ "header": "Notes", "action": "filter", "filters": [ "emailAddress" ] }
]
},
{
"worksheet": "Members",
"unlistedColumns": "redact",
"columns": [
{ "header": "Member ID", "action": "ignore" },
{ "header": "Plan", "action": "ignore" }
]
}
]
}
}
(The compiler writes one value per line. The JSON above is condensed.)
The compiler rejects rules that could not work, before the policy goes anywhere:
compile error: column filter 'ssn' is not defined in identifiers
compile error: More than one column rule for header 'SSN'
compile error: A redact column rule needs strategies
The first comes from filters = ['ssn'] in a policy with no SSN filter, the second from two rules for the same header, and the third from a redact rule without strategies.
Apply it
The input files hold invented data. claims.csv:
Claim ID;Member;Member SSN;Phone;Notes
CLM-1001;Jane Roe;123-45-6789;(217) 555-0142;Asked for a call back, email jane.roe@example.com
CLM-1002;John Doe;987-65;(217) 555-0175;Partial SSN on the form, call (217) 555-0199
claims.xlsx has a Claims worksheet with the same rows, and a Members worksheet:
| Member ID | Name | Date of Birth | Plan |
|---|---|---|---|
| M-2001 | Jane Roe | 1980-02-14 | Gold |
| M-2002 | John Doe | 1975-07-30 | Silver |
This Java program applies the compiled policy with Phileas, using CsvFilterService for the CSV file and OoxmlFilterService from the phileas-ooxml module for the workbook:
package com.example;
import ai.philterd.phileas.PhileasConfiguration;
import ai.philterd.phileas.model.filtering.BinaryDocumentFilterResult;
import ai.philterd.phileas.model.filtering.MimeType;
import ai.philterd.phileas.policy.Policy;
import ai.philterd.phileas.services.context.DefaultContextService;
import ai.philterd.phileas.services.disambiguation.vector.InMemoryVectorService;
import ai.philterd.phileas.services.filters.filtering.CsvFilterService;
import ai.philterd.phileas.services.filters.filtering.OoxmlFilterService;
import com.google.gson.Gson;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;
public class ApplyColumnRules {
public static void main(String[] args) throws Exception {
final Policy policy = new Gson().fromJson(Files.readString(Path.of("claims-export.json")), Policy.class);
final PhileasConfiguration configuration = new PhileasConfiguration(new Properties());
final CsvFilterService csv = new CsvFilterService(configuration,
new DefaultContextService(), new InMemoryVectorService(), null);
final BinaryDocumentFilterResult csvResult = csv.filter(policy, "claims",
Files.readAllBytes(Path.of("claims.csv")), MimeType.TEXT_CSV);
Files.write(Path.of("claims-redacted.csv"), csvResult.getDocument());
csvResult.getWarnings().forEach(w -> System.out.println("warning: " + w));
final OoxmlFilterService xlsx = new OoxmlFilterService(configuration,
new DefaultContextService(), new InMemoryVectorService(), null);
final BinaryDocumentFilterResult xlsxResult = xlsx.filter(policy, "claims",
Files.readAllBytes(Path.of("claims.xlsx")), MimeType.APPLICATION_XLSX);
Files.write(Path.of("claims-redacted.xlsx"), xlsxResult.getDocument());
xlsxResult.getWarnings().forEach(w -> System.out.println("warning: " + w));
}
}
claims-redacted.csv:
Claim ID;Member;Member SSN;Phone;Notes
CLM-1001;{{{REDACTED-full-column}}};***********;{{{REDACTED-phone-number}}};Asked for a call back, email {{{REDACTED-email-address}}}
CLM-1002;{{{REDACTED-full-column}}};******;{{{REDACTED-phone-number}}};Partial SSN on the form, call (217) 555-0199
Row by row, column by column:
Claim IDis unchanged, as itsignorerule says.- Every
Membervalue is replaced. AREDACTstrategy in a column rule writes{{{REDACTED-full-column}}}. - Every
Member SSNvalue is masked, including the partial987-65. The rule replaces the column whatever it holds, with no detection involved. Phonehas no rule, so it is scanned with every filter inidentifiers, and the phone filter redacts it.Notesis scanned only withemailAddress. The email address is redacted, and the phone number in the second row is kept. That is what the rule says, so add'phoneNumber'to itsfiltersif free-text phone numbers matter.
In claims-redacted.xlsx, the Claims worksheet has no entry of its own, so it follows the entry without a worksheet and comes out exactly like the CSV file. The Members worksheet follows its allow-list entry:
| Member ID | Name | Date of Birth | Plan |
|---|---|---|---|
| M-2001 | {{{REDACTED-full-column}}} | {{{REDACTED-full-column}}} | Gold |
| M-2002 | {{{REDACTED-full-column}}} | {{{REDACTED-full-column}}} | Silver |
Name and Date of Birth have no rule, so unlistedColumns = 'redact' replaces them. A column added to the export later is replaced as well until it gets an ignore rule.
Watch for headers that do not match
A rule matches a header by its exact text, trimmed. If an export renames Member SSN to SSN, the rule matches nothing, and the column falls back to unlistedColumns. With this policy, which has no SSN filter, the SSN values then pass through unchanged:
Claim ID;Member;SSN;Phone;Notes
CLM-1001;{{{REDACTED-full-column}}};123-45-6789;{{{REDACTED-phone-number}}};Asked for a call back, email {{{REDACTED-email-address}}}
CLM-1002;{{{REDACTED-full-column}}};987-65;{{{REDACTED-phone-number}}};Partial SSN on the form, call (217) 555-0199
Phileas returns a warning for each rule that matched no column, which the program above prints:
warning: The column rule for header 'Member SSN' matches no column.
Treat that warning as a failure in any automated pipeline, and include the SSN filter in identifiers as a second line of defense for columns that fall through. Detection in filter and unlisted columns is probabilistic, and a redact rule is only as good as the export’s headers, so check redacted output against your own files.
Where to go next
- Compiling PhiSQL policies in your build catches rule mistakes like the three above in CI.
- Phileas’s documentation for Word and Excel column rules and CSV covers embedded workbooks, per-call column overrides, and limits. These pages are in the main branch and not yet on the published documentation site.
- The PhiSQL specification defines every setting of
CONFIGURE CSVandCONFIGURE TABULAR SHEET.