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
Remove PII with n8n and OpenAI

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

Learn how to Build this Workflow with AI:

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

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.


Remove PII with n8n and OpenAI

Visit through Desktop to Interact with the Workflow.

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.
Author
Written By
Ritu Sanjali

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.