Import CSV Data from Public URL to Google Sheets with Upsert Logic - n8n Workflow

Automate fetching dynamic CSV data from any public URL and importing it into Google Sheets. This n8n workflow uses unique keys to efficiently append or update records.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Data analysts and researchers needing to regularly synchronize public datasets into Google Sheets.

  • Users running repeatable data imports where avoiding duplicates is critical.

  • Automation specialists looking for robust n8n templates for data fetching and synchronization.

  • Anyone managing processes requiring automated data updates based on a composite unique ID.

Overview

Manually downloading, cleaning, and uploading large CSV files from public sources can be time-consuming and prone to human error. This specialized n8n workflow solves this challenge by providing a fully automated, resilient data pipeline. This n8n template starts with an n8n trigger, fetches the remote CSV using the HTTP Request n8n node, and then efficiently processes the data. It strategically includes steps to create a composite unique ID and filter the data, which is essential for working with large datasets to manage Google Sheets API limits. The final Google Sheets n8n node utilizes the unique ID to execute an 'append or update' operation, guaranteeing that your spreadsheet remains up-to-date without creating duplicate entries. Using this n8n workflow ensures reliable data integration for external sources.

How it Works

The execution of this robust n8n workflow begins with the manual n8n trigger, 'When clicking "Execute Workflow"'.


  1. Download CSV: The workflow immediately proceeds to the HTTP Request n8n node, which downloads the CSV file content from the specified public URL.

  2. Import and Parse: The Import CSV n8n node (a Spreadsheet File n8n node) takes the raw file data and converts the content into structured JSON items, enabling further processing.

  3. Create Unique Key: The Add unique field n8n node utilizes the Set n8n node functionality to combine the countrycode and yearweek fields, generating a composite uniquekey. This key is vital for the upsert logic in the final step.

  4. Filter Data: The Keep only DACH in 2023 n8n node (a Filter n8n node) dramatically reduces the dataset size. As noted in the n8n template's sticky note, this is a critical optimization to avoid hitting Google Sheets API rate limits. It filters for records matching specific countries ('DE', 'AT', 'CH') and the year '2023'.

  5. Upsert to Sheets: Finally, the Upload to spreadsheet n8n node (a Google Sheets n8n node) executes the core append/update operation, using the generated uniquekey to match and update existing rows or append the data as new rows if no match is found, ensuring data synchronization integrity.

Installation Guide

To deploy this n8n workflow, follow these simple steps:


  1. Import: Copy the provided JSON code and paste it directly into your n8n instance via the 'New' menu and selecting 'Import from JSON'.

  2. Credentials: You will need to set up credentials for the Google Sheets n8n node.

Click on the 'Upload to spreadsheet' n8n node.
Under 'Credentials', select or create a new 'Google Sheets OAuth2 API' credential, granting it necessary access to modify your sheets.

  1. Configuration (Google Sheets):

* Ensure the Document ID URL and the target Sheet Name (e.g., 'COVID-weekly') in the 'Upload to spreadsheet' n8n node match your intended destination spreadsheet.

  1. Execution: Since this n8n template uses a manual n8n trigger, click 'Execute Workflow' to test the data pipeline, or replace the initial node with a Schedule n8n trigger for regular execution.

Node Details

When clicking "Execute Workflow" (Manual Trigger n8n trigger): The starting point of the n8n workflow, executed manually for testing or immediate operation.
Download CSV (HTTP Request n8n node): Fetches the raw CSV data from the external data URL (https://opendata.ecdc.europa.eu/...). Configured to treat the response as a file.
Import CSV (Spreadsheet File n8n node): Parses the downloaded CSV file content. Key setting: fileFormat is csv and headerRow is enabled.
Add unique field (Set n8n node): Performs data transformation. Creates the uniquekey by concatenating fields: {{ $json.countrycode }}-{{ $json.yearweek }}. This is essential for the upsert logic in the Google Sheets n8n node.
Keep only DACH in 2023 (Filter n8n node): Optimizes the n8n workflow performance by filtering items. Filters where yearweek starts with '2023' AND countrycode is 'DE', 'AT', or 'CH'.
Upload to spreadsheet (Google Sheets n8n node): The final action n8n node. Operation is set to appendOrUpdate, utilizing the unique
key as the matching column to prevent data duplication in the target sheet.

Related n8n Workflows

Free

Nodes: 0 Nodes
Updated: December 26 2025
View all
Created by
n8n Team
n8n Team

Meet the official n8n team. We specialize in building workflows that transform intricate tasks into seamless operations.

Featured*