Examples of de-identifying tabular data

Sensitive Data Protection can detect, classify, and de-identify sensitive data within structured data. When de-identifying content as a table, the structure and columns provide Sensitive Data Protection with additional clues that may enable it to provide better results for some use cases. For example, you can scan a single column for a certain data type instead of the entire table structure.

This topic provides examples of how to configure de-identification of sensitive data within structured text. De-identification is enabled through record transformations. These transformations are applied to values within tabular text data that are identified as a specific infoType, or to an entire column of tabular data.

This topic also provides examples of tabular data transformations using the cryptographic hash method. The cryptographic transformation methods are unique because of their requirement of a cryptographic key.

The JSON given in the following examples can be inserted into any de-identification request inside the "deidentifyConfig" (DeidentifyConfig) attribute. Click the "APIs Explorer example" link to try out the example JSON in APIs Explorer.

Transform a column without inspection

To transform a specific column in which the content is already known, you can skip inspection and specify a transformation directly. The example following the table buckets the "HAPPINESS SCORE" column into increments of 10.

Input Transformed table
AGE PATIENT HAPPINESS SCORE
101 Charles Dickens 95
22 Jane Austen 21
55 Mark Twain 75
AGE PATIENT HAPPINESS SCORE
101 Charles Dickens 90:100
22 Jane Austen 20:30
55 Mark Twain 70:80

C#

To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.

To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.


using System;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Dlp.V2;

public class DeidentifyUsingTableBucketing
{
    public static Table DeidentifyData(
        string projectId,
        Table tableToInspect = null)
    {
        // Instantiate dlp client.
        var dlp = DlpServiceClient.Create();

        // Construct the table if null.
        if (tableToInspect == null)
        {
            var row1 = new Value[]
            {
                new Value { StringValue = "101" },
                new Value { StringValue = "Charles Dickens" },
                new Value { StringValue = "95" }
            };
            var row2 = new Value[]
            {
                new Value { StringValue = "22" },
                new Value { StringValue =