HomeSpreadsheet AutomationAutomatically Combine CSV Files in Google Sheets (2026)

Automatically Combine CSV Files in Google Sheets (2026)

Combining daily CSV exports can become a repetitive task for small businesses.

A retail manager might download sales reports from an online store, a payment processor, and a point-of-sale system. An operations team may receive separate CSV files containing orders from different locations.

Each file contains useful information, but manually importing everything into Google Sheets creates several problems.

Employees may forget a file, accidentally import the same report twice, change important data formats, or spend too much time copying records between spreadsheets.

If you need to automatically combine CSV files in Google Sheets, Google Drive and Google Apps Script can help create a centralized reporting workflow.

Instead of opening every CSV file individually, an automated script can review a designated Google Drive folder, validate the data, combine new records, and maintain a history of processed files.

In this tutorial, you’ll learn how to build that system from scratch.

We’ll cover CSV formatting, automatic imports, duplicate prevention, file tracking, scheduling, common errors, and practical ways to use the consolidated data for business reporting.

You’ll also find a downloadable sample project containing the Apps Script code and fictional CSV files for testing the process.

Can Google Sheets Automatically Combine Multiple CSV Files?

Yes. Google Sheets can import CSV data, and Google Apps Script can automate the process of reading multiple files from Google Drive.

Google provides an official CSV import automation example that uses a time-driven trigger to process files from a folder.

That approach is useful when several CSV exports share the same structure.

For example, imagine receiving these files:

  • sales_day_01.csv
  • sales_day_02.csv
  • sales_day_03.csv

Each contains sales records with identical column headings.

You could import each file manually or use an automated workflow that consolidates them into one Google Sheet.

Example CSV Data

The first file contains:

Order ID Order Date Customer Amount Status
US-1001 2026-10-01 Avery Lane 149.00 Paid
US-1002 2026-10-01 Morgan Reed 39.50 Pending

The second file contains:

Order ID Order Date Customer Amount Status
US-1002 2026-10-01 Morgan Reed 39.50 Pending
US-1003 2026-10-02 Jordan Lee 84.25 Paid

Notice that order US-1002 appears in both files.

A basic append operation would produce four rows.

Our example will identify the duplicate Order ID and retain three distinct orders instead.

What the Automation Will Do

The workflow looks like this:

New CSV Files in Google Drive → Validate Headers → Check Existing Order IDs → Append New Records → Record Import Results

A time-driven trigger can execute the process automatically.

This avoids manually opening every CSV file when new exports become available.

Three Ways to Combine CSV Files in Google Sheets

Before writing code, consider the available methods.

Method Automation level Best use
Google Sheets manual import Manual Occasional small files
Google Apps Script Scheduled automation Repeated CSV files in Drive
Zapier, Make, or n8n Workflow-dependent Files arriving from connected applications

Method 1: Import CSV Files Manually

In Google Sheets, use:

File → Import → Upload

Select a CSV file and choose the appropriate import behavior.

This is suitable for occasional exports.

However, importing files manually becomes inconvenient when new reports arrive every day.

Method 2: Use Google Apps Script

Apps Script can read files from a Google Drive folder, interpret their CSV contents, and write rows into a spreadsheet.

It also supports scheduled execution.

This is the approach we’ll implement.

Method 3: Use a No-Code Automation Platform

Tools such as Make, Zapier, and n8n can connect business applications and transfer data between supported services.

These tools may be preferable when CSV exports arrive through email attachments, APIs, or other connected systems.

However, their workflows still need appropriate duplicate-prevention and error-handling logic.

Step 1: Prepare Your CSV Files

Before combining files, make sure they use a consistent structure.

For this tutorial, every CSV file must have these five columns in the exact order shown:

Order ID,Order Date,Customer,Amount,Status

An example file:

Order ID,Order Date,Customer,Amount,Status
US-1001,2026-10-01,Avery Lane,149.00,Paid
US-1002,2026-10-01,Morgan Reed,39.50,Pending

Required CSV Format

Our example expects:

Field Requirement
Order ID Unique, nonempty identifier
Order Date YYYY-MM-DD
Customer Nonempty text
Amount Nonnegative USD amount, up to two decimals
Status Paid, Pending, Refunded, or Canceled

The files should be encoded in UTF-8 and use commas as the field delimiter.

Why Identical Headers Matter

Suppose one file contains:

Order ID,Order Date,Customer,Amount,Status

Another contains:

ID,Date,Buyer,Price,Payment Status

Those files may describe similar information, but the column names aren’t identical.

A simple automated merge cannot safely assume that the columns mean exactly the same thing.

Our script rejects unexpected headers so a supplier export change doesn’t silently corrupt the reporting table.

For businesses combining different schemas, create a separate field-mapping process.

Step 2: Create a Google Drive Folder for Incoming CSV Files

Open Google Drive.

Create a new folder named:

Business CSV Imports

This folder will hold the source CSV files.

Upload Your Sample Files

Upload the two fictional CSV files included with this tutorial’s starter kit.

They contain three unique orders, including one repeated Order ID.

Copy the Folder ID

Open the folder in Google Drive.

Its URL will resemble:

https://drive.google.com/drive/folders/YOUR_FOLDER_ID

Copy the folder identifier from the URL.

You’ll use that value when configuring Apps Script.

Important Folder Permissions

Restrict access to the folder.

CSV files may contain customer names, financial information, business activity, or other confidential data.

Avoid making a business data-import folder publicly accessible.

Also, the script must run under an account that has permission to read the folder.

Step 3: Create the Destination Google Sheet

Open Google Sheets and create a blank spreadsheet.

Name it:

Consolidated Business Orders

The script will create two worksheets automatically if they don’t already exist.

Orders Worksheet

This sheet stores the consolidated records.

Column Header
A Order ID
B Order Date
C Customer
D Amount
E Status
F Source File ID
G Imported At

ImportLog Worksheet

This sheet records import activity.

Column Header
A File ID
B File Name
C State
D Rows Added
E Rows Skipped
F Started At
G Finished At
H Message

The separation is intentional.

Orders contains the business data.

ImportLog contains information about how that data was processed.

An import log helps employees diagnose failed files without mixing operational messages with customer records.

Download the Free Google Sheets CSV Automation Starter Kit

To make this tutorial easier to follow, we’ve prepared a free Google Sheets CSV Automation Starter Kit that includes the files needed to practice automatically importing and combining CSV data using Google Apps Script.

Instead of creating every test file from scratch, you can download the complete package and follow the practical examples in this guide.

What’s Included in the Starter Kit?

  • Code.gs: Google Apps Script code for importing CSV files from Google Drive, validating records, detecting duplicates, and tracking import activity.
  • sales_day_01.csv: A sample sales report containing fictional customer orders.
  • sales_day_02.csv: A second sample CSV file containing additional orders and a duplicate record to test the deduplication process.
  • README: Setup instructions explaining how to configure the import workflow and test it safely.

Download the Starter Kit

Download the Free Google Sheets CSV Automation Starter Kit (ZIP) — Google Drive

The download is free and includes sample data for educational and testing purposes.

How to Use the Downloaded Files

  1. Open the Google Drive download link above and download the ZIP package.
  2. Extract the ZIP file to your computer.
  3. Open your Google Sheets spreadsheet and navigate to Extensions → Apps Script.
  4. Open the included Code.gs file, copy its contents, and paste the code into your Apps Script project.
  5. Upload sales_day_01.csv and sales_day_02.csv to your designated Google Drive import folder.
  6. Configure the folder ID and keep dry-run mode enabled for the initial test.
  7. Follow Step 4: Add the CSV Import Script and the subsequent steps in this guide to validate your setup.

The sample files include a repeated Order ID, allowing you to verify whether the automation correctly prevents duplicate records.

Important: Always test with the fictional sample data before connecting the script to real customer records, financial reports, or business-critical spreadsheets.

Once you’ve downloaded and extracted the starter kit, continue to Step 4: Add the CSV Import Script to configure your automated CSV import workflow.

Step 4: Add the CSV Import Script

In the destination spreadsheet, select:

Extensions → Apps Script

Create a new script project.

The complete production-style starter example is included in the downloadable project accompanying this tutorial.

The essential configuration looks like this:

const CSV_CONFIG = {
  folderId: 'PASTE_INPUT_FOLDER_ID',
  dataSheet: 'Orders',
  logSheet: 'ImportLog',
  dryRun: true,
  maxFilesPerRun: 15,
  maxRowsPerFile: 1000
};

Replace PASTE_INPUT_FOLDER_ID with the actual Google Drive folder ID.

What the Settings Mean

folderId: Identifies where the CSV files are stored.

dataSheet: Names the worksheet holding consolidated data.

logSheet: Names the worksheet recording import results.

dryRun: Controls whether the script only previews the results or actually modifies the spreadsheet.

maxFilesPerRun: Limits how many eligible files the script processes during one execution.

maxRowsPerFile: Rejects files exceeding the chosen record limit.

These limits are conservative defaults for a small-business example.

They help avoid processing unexpectedly large batches during initial tests.

How the Script Parses CSV Files

Google Apps Script provides a CSV parser:

const data = Utilities.parseCsv(csvText);

The method returns a two-dimensional array containing the parsed rows and columns.

Google documents this in the Utilities.parseCsv reference.

This approach is preferable to simply splitting a CSV file at every comma.

For example, a valid CSV field may contain quoted text with an embedded comma:

Order ID,Order Date,Customer,Amount,Status
US-1004,2026-10-03,"Smith, Johnson LLC",250.00,Paid

A simple split(",") operation would misinterpret the customer field.

A CSV-aware parser handles ordinary quoted CSV fields more appropriately.

Step 5: Validate Files Before Importing

One of the most important safeguards is checking the structure of each CSV before appending its contents.

Our example compares the incoming header row with the expected column names.

The underlying principle is:

const expected = [
  'Order ID',
  'Order Date',
  'Customer',
  'Amount',
  'Status'
];

const actual = parsedRows[0].map(
  value => String(value).trim()
);

if (actual.join('|') !== expected.join('|')) {
  throw new Error('Unexpected CSV columns.');
}

This is an illustrative excerpt; the full downloadable script uses a safer comparison separator and additional validation.

Additional Validation

The complete script also checks:

  • Missing Order IDs.
  • Empty customer names.
  • Incorrect column counts.
  • Invalid calendar dates.
  • Invalid amounts.
  • Unexpected status values.
  • Files exceeding the configured size limit.

Example: Invalid Amount

Suppose an export contains:

US-1005,2026-10-04,Test Customer,ABC,Paid

The Amount field contains text rather than the expected numeric value.

Our importer rejects the file for manual review.

It does not silently convert the value to zero.

This is important because changing an invalid amount into a real number could misrepresent business reporting.

Step 6: Prevent Duplicate Orders

Duplicate data is a major problem when combining recurring exports.

For example, a sales system may generate a full list of recent orders every day rather than exporting only new ones.

If you append every row, the same order could appear repeatedly.

Use a Stable Order ID

Our example uses Order ID as the deduplication key.

Before importing new records, it reads the identifiers already present in the destination sheet.

The basic logic is:

const existingIds = new Set(
  existingOrderIds
);

if (existingIds.has(orderId)) {
  // Skip this previously imported order.
  continue;
}

The complete script also detects repeated Order IDs within the same CSV file.

Example

File A:

US-1001
US-1002

File B:

US-1002
US-1003

After processing both files, the Orders worksheet contains:

US-1001
US-1002
US-1003

The second occurrence of US-1002 is skipped.

Important Limitation: What If an Existing Order Changes?

Imagine that order US-1002 was originally Pending.

A later CSV file shows it as Paid.

The example importer’s default rule is to keep the first imported record, not update existing records.

It skips the repeated Order ID even if other fields changed.

Therefore, this is an append-only consolidation workflow, not a complete order synchronization engine.

If your business needs order status changes to update existing rows, implement a separate, carefully designed upsert process using the source system’s update timestamps or version identifiers.

Do not treat an append-only importer as a reliable real-time order database.

Step 7: Track Previously Processed Files

Order-level duplicate prevention is helpful, but file-level tracking provides another safeguard.

Google Drive assigns each file a unique identifier.

The script records this identifier in the ImportLog worksheet.

Example Import Log

File Name State Rows Added Rows Skipped
sales_day_01.csv DONE 2 0
sales_day_02.csv DONE 1 1

If the importer encounters the same file ID again, it skips it.

This avoids repeatedly parsing files that have already been handled.

Why File IDs Are Better Than File Names Alone

Two Google Drive files can have the same name.

For example:

sales.csv

A business might upload different files using that name on different days.

The Google Drive file ID identifies the actual file object.

What Happens When a File Fails?

The example script records a state such as:

REVIEW

If an execution stops unexpectedly, a file may remain marked:

PROCESSING

These states require manual investigation.

The script does not automatically retry those files because their rows may already have been written before the failure.

This conservative approach reduces the risk of accidentally duplicating records after an interrupted import.

Can You Reprocess a Failed File?

Yes, after determining what happened.

First inspect the Orders worksheet and ImportLog.

Correct any source-data problem.

Then use a controlled recovery procedure, such as uploading a corrected file as a new Drive file after reconciling existing Order IDs.

Do not simply delete failed log entries without checking whether rows were already imported.

Step 8: Test With Dry-Run Mode

Before the script modifies business data, keep:

dryRun: true

This mode reads and validates files, identifies candidate rows, and reports the results in the execution log.

It does not append orders or mark files as successfully imported.

Test Procedure

  1. Upload the two sample CSV files to the Google Drive folder.
  2. Set the folder ID in the script.
  3. Save the project.
  4. Run importCsvFromDrive.
  5. Complete Google’s required authorization.
  6. Open Executions and inspect the logs.

Expected Test Result

The first CSV contains two new orders.

The second CSV contains one repeated order and one new order.

Therefore, the dry-run output should identify three unique orders across the two files.

Enable Actual Importing

After confirming the result, change:

dryRun: false

Run the function again.

Open the Orders worksheet.

You should find three distinct order records.

Open ImportLog and verify that both files are recorded as completed.

Test Duplicate Prevention

Run the script again with the same files.

The importer should not append those records again.

This verifies that the file tracking works.

Test a New File

Create a third fictional CSV with a new Order ID.

Upload it to the same folder.

Run the importer again.

Only that new order should be appended.

Step 9: Schedule Automatic CSV Imports

After testing, you can automate the workflow.

Google Apps Script supports installable time-driven triggers.

Open the script editor.

Select:

Triggers → Add Trigger

Configure:

Setting Value
Function importCsvFromDrive
Event source Time-driven
Frequency Daily, or another suitable interval

Save and authorize the trigger.

Google’s installable triggers documentation explains how recurring executions operate.

Will the Script Run Immediately When a CSV Is Uploaded?

Not in this example.

The script checks the folder on its configured schedule.

If the trigger runs daily, a file uploaded after that day’s execution may not be processed until the next scheduled run.

Google Apps Script’s ordinary time-driven triggers also do not guarantee an exact execution minute.

Should You Use Hourly or Daily Imports?

It depends on the business.

Business requirement Possible schedule
Monthly administrative report Monthly
Daily sales summary Daily
Several order exports per day Hourly
Immediate order fulfillment Event-driven integration may be better

For time-critical inventory or fulfillment decisions, a scheduled spreadsheet importer may not provide sufficient freshness or delivery guarantees.

Use the source platform’s supported events or API when reliable near-real-time processing is required.

Step 10: Create a Sales Reporting Dashboard

Once the orders are consolidated, you can create a simple reporting dashboard.

Create another worksheet named:

Dashboard

Count Imported Orders

=COUNTA(Orders!A2:A)

Calculate Total Paid Order Value

=SUMIF(Orders!E2:E,"Paid",Orders!D2:D)

This sums the amount associated with records marked Paid.

It does not automatically mean that the amount equals net revenue or cash settled.

Fees, refunds, taxes, and payment settlement details may require separate treatment.

Count Pending Orders

=COUNTIF(Orders!E2:E,"Pending")

Count Successfully Imported Files

=COUNTIF(ImportLog!C2:C,"DONE")

Count Files Requiring Review

=COUNTIF(ImportLog!C2:C,"REVIEW")

Example Dashboard

Metric Illustrative value
Unique orders 1,250
Paid order value $82,450
Pending orders 37
Processed CSV files 42
Files requiring review 2

These numbers are fictional examples.

For more accurate financial reporting, use the source system’s transaction definitions and verify how refunds, cancellations, taxes, and currency conversions are represented.

How to Handle CSV Data Quality Problems

Even a functioning import script can produce unreliable reports if the source data is inconsistent.

Different Date Formats

One file might use:

2026-10-19

Another might use:

10/19/2026

Our script requires the ISO format YYYY-MM-DD.

This reduces ambiguity between different date conventions.

The imported date is preserved as an ISO-formatted text value in this example. If you need date calculations, convert it using a validated date transformation or a separate reporting column.

Currency Differences

A CSV may contain amounts in different currencies.

For example, a US store may sell products in USD and CAD.

Our example assumes nonnegative USD amounts.

Don’t simply combine values from multiple currencies and label the total as dollars.

Include a Currency field and an appropriately documented conversion process if your source data spans several currencies.

Missing Customer Information

A record may contain a valid order ID but no customer name.

The example rejects that file rather than silently substituting an invented name.

Formula Injection

CSV values can contain text beginning with characters interpreted by spreadsheet software as formulas.

For example, an untrusted Customer field might contain formula-like text.

Google Sheets treats values beginning with = as formulas when written using certain spreadsheet methods.

The example script applies a text-safety measure to fields that may begin with spreadsheet formula operators.

The relevant behavior is described in Google’s Apps Script Range documentation.

This is one safeguard. Organizations processing untrusted CSV files should still apply appropriate input validation and data-security practices.

Different File Encodings

The sample workflow expects UTF-8 text.

Files exported using another character encoding may produce corrupted customer names or other incorrect values.

Standardize exports before importing them.

Google Apps Script Limits and Performance

Google Apps Script is convenient for small and moderately sized automation tasks, but it has execution and service limits.

The starter script deliberately processes a limited number of files and rows in one execution.

These limits are configurable.

Why Not Import Thousands of Files at Once?

Processing a very large folder can consume significant execution time.

Likewise, reading and writing hundreds of thousands of spreadsheet rows may exceed practical performance limits.

Google publishes its Apps Script service quotas, including execution and service restrictions.

When to Consider a Database

A database or managed data pipeline may be preferable when:

  • Several systems continuously update the same records.
  • Large volumes of files arrive frequently.
  • Exact transactional guarantees are required.
  • Historical records must be updated.
  • Several employees or services write concurrently.
  • Reports require extensive joins and transformations.
  • Strict auditing and recovery are necessary.

Google Sheets can be an effective reporting interface, but it should not automatically be treated as a replacement for a transactional database.

Common Google Sheets CSV Import Problems

The Script Cannot Find the Drive Folder

Check the folder ID and the Google account running the script.

The account must have permission to access the folder.

The CSV File Is Not Imported

Confirm that its filename ends in .csv.

Check whether its file ID already exists in ImportLog.

Inspect the log for REVIEW or PROCESSING states.

The Script Reports a Header Mismatch

Verify that the CSV contains the expected column names in the correct order.

Don’t bypass validation unless the source format has been deliberately reviewed.

Orders Are Repeated

Check whether each order has a stable, unique identifier.

If separate systems generate overlapping IDs, a composite business key such as Source System plus Order ID may be required.

Some Updated Orders Are Missing

The example uses append-only deduplication.

A repeated Order ID is skipped even if other fields changed.

Use a supported upsert process when updates must be reflected.

CSV Fields Contain Incorrect Characters

Check whether the source uses UTF-8 and standard comma-separated formatting.

The Script Stops After Processing Some Files

Review Apps Script execution errors and the import log.

Do not delete processed records or rerun failed files blindly.

The Scheduled Import Doesn’t Run

Confirm the time-driven trigger exists and is authorized.

Check the Executions panel for errors and service quota issues.

Google Sheets CSV Automation vs. Power Query

Small businesses sometimes choose between Google Sheets and Excel Power Query for consolidating files.

Both tools can be useful, but their workflows differ.

Requirement Google Sheets + Apps Script Excel Power Query
Combine files Yes, with custom logic Supported transformations
Read Google Drive files Apps Script / Drive service Depends on supported connection
Read local folders Requires transfer to accessible source Folder connector in supported desktop Excel
Schedule execution Time-driven Apps Script Depends on refresh environment
Validate columns Custom script Query transformations
Prevent duplicate records Custom logic Query transformations
Track individual processed files Custom log Requires appropriate design
Update historical records Additional logic Depends on transformation and load design

If you’re working primarily with Excel, our Excel Power Query not refreshing troubleshooting guide explains how to diagnose broken connections and automatic refresh limitations.

For a Google Workspace-based business, Apps Script may be a natural option.

The correct choice depends on where the source files originate and how frequently the data must be updated.

How CSV Automation Connects With Other Business Workflows

CSV consolidation often supports inventory, purchasing, and operational reporting.

For example, a business might import daily sales exports and use the results to understand demand.

Its inventory system can then identify products nearing a reorder threshold.

Our Google Sheets inventory tracker with low-stock alerts guide explains how to organize stock quantities and purchasing alerts.

If purchasing staff decide to order replacement goods, the Google Sheets purchase order generator tutorial describes how approved purchase orders can be converted into supplier PDFs.

For more complex integrations, a company may use Make.com.

If scheduled workflows stop processing new data, our Make.com scenario not running automatically guide covers scheduling, trigger, and execution troubleshooting.

Keep each workflow’s purpose clear.

Importing sales data is not the same as updating live stock balances or authorizing purchasing decisions.

Frequently Asked Questions

Can Google Sheets automatically combine CSV files?

Yes. Google Apps Script can read multiple CSV files from a Google Drive folder and append their records to a consolidated spreadsheet.

How do I merge multiple CSV files into one Google Sheet?

You can import them manually or use Apps Script to read each file, validate its contents, and append its rows to a destination worksheet.

Can Google Sheets automatically import new CSV files from Drive?

Yes. A time-driven Apps Script trigger can check a Drive folder at scheduled intervals and process eligible files.

How do I prevent duplicate records when combining CSV files?

Use a stable unique identifier such as Order ID.

Compare incoming identifiers with previously imported records and skip or otherwise handle duplicates according to your business rules.

Can the script skip previously imported files?

Yes. The example records Google Drive file IDs in an ImportLog worksheet and skips files that have already been handled.

Does the importer update an existing order if its status changes?

No. The provided example keeps the first record and skips repeated Order IDs.

To update existing orders, build a separate upsert workflow with suitable conflict resolution.

Can Google Apps Script read CSV files with quoted commas?

Yes. The Utilities.parseCsv method supports CSV parsing and is more appropriate than simply splitting every line at commas.

Can Google Sheets import CSV files every hour?

Yes. Installable time-driven triggers support recurring script execution.

Actual scheduling precision and applicable quotas depend on Google Apps Script.

Can I combine CSV files with different columns?

Yes, but the columns must first be mapped to a consistent schema.

The example deliberately rejects files with unexpected headers.

Does this system require a paid Google Workspace account?

Apps Script and Google Sheets are available through Google accounts, subject to applicable service limits and organizational restrictions.

Additional platforms or enterprise data requirements may involve paid services.

Why does my CSV importer stop working?

Common causes include invalid folder permissions, mismatched headers, unsupported data formats, missing authorizations, execution limits, or unresolved file-processing states.

Check the execution history and ImportLog.

Is Google Sheets suitable for large CSV data pipelines?

It can handle many smaller reporting workflows, but large-scale or transactional data processing may be better suited to databases and dedicated data pipelines.

Final Thoughts

Learning how to automatically combine CSV files in Google Sheets can help small businesses reduce repetitive spreadsheet work and maintain more consistent reporting.

Google Drive provides a convenient location for incoming files.

Google Apps Script can inspect their contents, validate required fields, identify duplicate records, and append new information to a central spreadsheet.

A separate import log also makes it easier to see which files were processed successfully and which require investigation.

However, accurate reporting depends on more than successful imports.

Businesses need stable record identifiers, consistent CSV formats, sensible validation rules, and a safe way to recover from interrupted operations.

Start with the fictional CSV files supplied in this tutorial.

Test the workflow in dry-run mode, verify the results, and confirm duplicate prevention before introducing real business data.

For more practical tutorials involving Google Sheets inventory automation, purchase order generation, and spreadsheet troubleshooting, explore IA Network.

Reliable CSV automation is not simply about combining files. It’s about preserving data quality, preventing repeated records, and making each import easy to verify.

RELATED ARTICLES

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments