Remove PII from Google Drive CSVs with n8n & OpenAI

This workflow automates the removal of personally identifiable information (PII) from CSV files in Google Drive. By monitoring a specific folder, extracting PII columns via OpenAI, and saving sanitized files back to Drive, it drastically reduces manual data cleaning errors and saves hours each week.
googleDriveTrigger
openAi
code
+6
Workflow Identifier: 1550
NODES in Use: Google Drive Trigger, Google Drive, Extract from File, OpenAI, Merge, Upload to Drive, Split Out, Code, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow watches a Google Drive folder for new CSV files.

It finds and removes columns with personal information like names or emails.

The workflow saves a clean CSV without private data in another folder.

This helps avoid mistakes and saves hours of manual checking.


Inputs, Processing, and Outputs

Inputs

  • A new CSV file uploaded to a specified Google Drive folder.

Processing Steps

  • Trigger: Detect new file in the Google Drive folder.
  • Download: Get the file content from Google Drive.
  • Extract: Parse CSV into rows and columns.
  • Analyze: Use OpenAI GPT-4 to find which columns hold personal info (PII).
  • Remove PII: Delete those columns using a code node.
  • Save: Upload a new CSV file without PII to a different folder.

Outputs

  • A clean CSV file that has no PII columns.
  • The new file is saved in a second Google Drive folder.

Beginner Step-by-Step: How to Run This Workflow in n8n

Importing the Workflow

  1. Download the workflow file using the Download button on this page.
  2. Open the n8n editor where you build workflows.
  3. Use the Import from File option to upload the downloaded file.

Configuring Credentials and IDs

  1. Add the required Google Drive OAuth2 credentials in n8n.
  2. Add the OpenAI API Key for access to GPT-4 in the OpenAI node.
  3. Update the folder IDs in the Google Drive Trigger and upload nodes to match your Drive folders.
  4. Check the prompt inside the OpenAI node to confirm it matches the one below for PII detection:
Analyze the provided tabular data and identify the columns that contain personally identifiable information (PII). Return only the column names that contain PII, separated by commas.

Testing the Workflow

  1. Upload a sample CSV file to the monitored Google Drive folder.
  2. Watch the workflow trigger and run step-by-step links in n8n.
  3. Check that the clean CSV file without PII appears in the destination folder.

Activating for Production

  1. Turn on the workflow using the toggle switch in n8n.
  2. The workflow now runs automatically every minute, handling new CSV uploads.
  3. Monitor execution logs for errors and fix if needed.

If you are interested in self hosting n8n, see this resource for guidance: self-host n8n.


Tools and Services Used

  • Google Drive API: Watches folder, downloads and uploads CSV files.
  • OpenAI GPT-4 (model gpt-4o-mini): Analyzes CSV headers to spot PII columns.
  • n8n Automation Platform: Connects nodes and automates the full process.

Customization Ideas

  • Change Google Drive folders monitored or saved to by updating folder ID settings.
  • Swap OpenAI GPT-4 model for another if desired, keeping prompt adjusted.
  • Set the Google Drive Trigger polling interval to reduce API use.
  • Change filename suffix in the code node to suit naming rules.
  • Save sanitized files in subfolders or archives as backup.

Common Problems and Fixes

Error: “PII column names are missing in the input data.”

The OpenAI node did not return the column names as expected, or the node extracting the message was misconfigured.

Check the OpenAI output in the run log to confirm the response is correct.

Verify the Split Out node targets the exact message.content.content field.

New files do not trigger the workflow

Incorrect folder ID or Google Drive credentials often causes no trigger.

Confirm the folder ID is correct from the Drive URL and credentials are authorized.

Adjust polling if triggers are missed.

Sanitized files are empty or malformed

JavaScript errors in the code node may cause faulty output.

Check CSV structure and code syntax.

Make sure data merges are correct before processing.


Conclusion

This workflow removes personal data from new CSV files automatically.

It saves users hours of work and reduces privacy risks.

The output is clean CSV data ready for safe analysis or sharing.

You can build on this foundation to add alerts or distribute sanitized data.

Automating data cleaning helps teams save time and stay compliant.


Summary

✓ Workflow detects new CSVs in Google Drive.

✓ It uses AI to find and remove personal information fields.

✓ Saves sanitized CSVs into a safe folder automatically.

→ This process cuts manual work and reduces data leak risks.

→ Users get ready-to-use privacy-safe data files for analysis.


Frequently Asked Questions

Yes, the OpenAI node can be replaced with other AI tools that support text classification if their output format matches the code node requirements.
Yes, every OpenAI API call consumes credits based on the subscription, and frequent Google Drive polling also counts towards API limits.
Data is processed securely inside n8n and OpenAI’s environment. For more privacy, users can consider self hosting n8n on their own servers.
The workflow can handle moderate volume if API rate limits and polling frequency are managed. Scaling may require adjusting polling or batching uploads.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free