n8n

How to Automate Google Drive PII Removal?

Protect shared CSV files without extra manual work. The flow watches a Google Drive folder, removes columns with personal data, and saves a clean copy for safe use across teams.

Here is how it works. A Google Drive Trigger checks a chosen folder every minute for a new file. The file is downloaded and read by Extract from File to get the headers and rows. OpenAI reviews the table and returns only the column names that look like PII. One node pulls the original file name, another extracts the model result. A Merge node lines up the filename, the data, and the PII list. A Code node removes those columns and rebuilds a clean CSV. The Upload to Drive node saves the scrubbed file in a target folder with a clear name.

You will need Google Drive and OpenAI credentials. Expect to cut review time from about 30 minutes per file to around 2 minutes of automated work. Great for sales exports, support logs, HR reports, and vendor handoffs where sensitive fields should not leave your drive. Start with one sample CSV to confirm the flagged columns match your policy. If needed, tweak the OpenAI prompt or the Code node to match your rules.

What are the key features?

  • Google Drive Trigger watches a specific folder for new CSV files every minute.
  • Google Drive node downloads the file content for processing.
  • Extract from File parses the CSV to read headers and rows.
  • OpenAI identifies which column names look like PII and returns them as JSON.
  • SplitOut nodes pull the original filename and the model result for later use.
  • Merge combines data, PII list, and filename into one item for clean removal.
  • Code node removes PII columns and rebuilds a clean CSV string.
  • Upload to Drive saves the sanitized file in a chosen folder with a clear name.

What are the benefits?

  • Reduce manual cleanup from 30 minutes to 2 minutes per file
  • Improve data quality by removing sensitive fields before analysis
  • Eliminate most human errors in redaction through a repeatable flow
  • Handle up to 10 times more files without adding staff
  • Connect Google Drive and OpenAI in one simple process

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Google Drive and OpenAI. See the Tools Required section above for links to create accounts with these services.
  3. Open the Google Drive Trigger node. In the credential dropdown, click Create new credential and follow the on screen steps to connect your Google account. Choose the folder to watch and confirm the event is fileCreated with a one minute interval.
  4. Open the Google Drive download node. In the credentials dropdown, select the same Google Drive credential. Keep the fileId expression and binary property name set to data.
  5. Open Extract from File. Set the input to read the binary field named data. Choose CSV and confirm the parser reads headers correctly.
  6. Open the OpenAI node. In the credential dropdown, click Create new credential, then paste your API key from the OpenAI account API page. Keep jsonOutput enabled and the provided system prompt that asks for PII column names.
  7. Check the SplitOut nodes. For Get filename, confirm it reads the name field and stores it in originalFilename. For Get result, confirm it reads message.content.content and stores it in data.
  8. Open the Merge node. Ensure all three inputs are connected and the mode merges items by position so the filename, data, and PII list align.
  9. Open the Code node named Remove PII columns. Ensure the script uses the PII list from the first item and removes those headers from the CSV. Keep output fields for fileName and content.
  10. Open the Upload to Drive node. Select your Google Drive credential. Choose the target folder for clean files. Make sure operation is Create from Text, name uses the expression for fileName, and content uses the expression for content.
  11. Save and activate the workflow. Upload a test CSV with email and phone columns to the watch folder. After one minute, check the output folder for a clean file and confirm those columns are gone.
  12. Troubleshooting: If no file appears, check Drive permissions for both folders. If the model output is empty or not JSON, simplify column headers or adjust the prompt. If parsing fails, verify the file is CSV and confirm the Extract from File settings.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Google Drive

Sign up

Drive API: $0 (no additional cost; quota-limited)

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.