View Categories

Combine Multiple CSV Files Into One Table

19 min read

CSV FOLDER CONNECTOR

Combine Multiple CSV Files Into One Table

Stop stitching exports together by hand. Point Query Streams at the folder and every CSV in it becomes one queryable SQL table — new files join automatically, and you can still tell which file every row came from.

Thousands of files New files auto-join Money stays exact Nothing uploaded
\\reports\sales
jan.csv feb.csv mar.csv + 33 more
one table
SELECT region,
       SUM(revenue)
FROM sales
GROUP BY region;

Query Streams is a secure, real-time database integration platform that turns a whole folder of CSV files into one live SQL table you can query from Microsoft Excel, Google Sheets, Airtable and your AI assistant. Learn more at QueryStreams.com and sign up for free to combine your first folder of CSVs in minutes.

Combining CSV files is one of those jobs that looks trivial until you actually do it. Copy-pasting works for three files. At thirty it is an afternoon. At three hundred it is a script somebody has to maintain, and at three thousand it is a data pipeline nobody signed up to own.

The awkward part is that the job never finishes. A new export lands tomorrow, so whatever you merged today is already stale. A CSV Folder connector deals with that by never producing a merged file at all. It presents the folder as a SQL table, live. Add a file and it is simply in the table on the next sync.

A folder of exports
sales_2026_06.csv sales_2026_07.csv sales_2026_08.csv tomorrow’s file
One SQL table
sales every column, every file _source_file per row already included

How this differs from the usual ways to merge CSV files

There is no shortage of ways to combine CSV files. The distinction that matters is whether you end up with a merged artifact that goes stale, or a live view that does not.

ApproachStays currentWhat it costs you
Copy and paste in Microsoft Excel No Manual every time, and the row limit stops you at roughly a million rows.
Power Query “From Folder” On refresh Lives inside one workbook, needs a refresh, and loads every row into the file.
A Python or PowerShell script When it runs Somebody owns, schedules and debugs it — usually the person who wrote it.
An online CSV merger No You upload your data to a stranger’s server. For anything commercial, that is the end of the conversation.
Query Streams CSV Folder Always Nothing is merged, uploaded or copied — the folder is queried where it sits.

The other practical difference is reach. A Power Query merge lives in the workbook that owns it. A Query Streams connector is a data source, so the same combined table is available in Microsoft Excel, Google Sheets, Airtable, Smartsheet, Nova AI and your AI assistant at the same time — and it joins to your existing databases like any other table.

What happens on the first sync

Query Streams samples up to 64 files in the folder and works out three things they must agree on: the character encoding, the dialect (delimiter, quote character, escape character, whether there is a header row) and the columns and their types. That agreed shape becomes the table definition, and it is pinned — written down and defended from then on.

Agreement is required, not assumed. If half the files are comma-separated and half are semicolon-separated, the connector refuses to pin and tells you which files disagreed and how, rather than picking a winner and quietly dropping the rest. The same applies to types: if order_id is a number in most files and text in one, that is a named refusal, not a silent cast.

Once pinned, every file is read strictly against that definition. A row that does not fit the pinned types is never coerced or skipped — the file it belongs to is parked instead, which is covered further down.

Character encoding, the thing that breaks most merges

If you have ever merged CSV files and ended up with é where an é should be, or a mangled pound sign, you have met the encoding problem. It happens because most merge tools assume every file is UTF-8, and exports from Windows applications frequently are not.

Query Streams detects encoding per file rather than assuming. It checks for a byte order mark first, then attempts a strict UTF-8 decode; if that fails, it treats the file as Windows-1252, which is what most BOM-less Windows exports actually are. Files that are not natively readable are streamed through a transcoder in 64 KB chunks, so a 2 GB file never has to fit in memory.

EncodingAlso accepted asTypical source
utf-8utf8Modern exports, most databases, anything web-generated
cp1252windows-1252Microsoft Excel “Save as CSV” on Windows, older line-of-business systems
latin-1latin1, iso-8859-1Older European systems and mainframe extracts
utf-16leutf-16, utf16Excel “Unicode Text”, PowerShell redirects
utf-16beSome Java and mainframe exports
Windows-1252 is not treated as Latin-1, deliberately. The two encodings agree on most bytes but disagree on the range that holds smart quotes, the euro sign and the dagger. Treating one as the other would turn a curly apostrophe into an invisible control character — a wrong answer that looks like a right one. Query Streams keeps them distinct instead.

Encoding must be consistent across the folder. Mixed encodings are a named refusal listing which files were detected as what, so you can either fix the odd file out, exclude it, or set encoding explicitly and have every file read the same way.

Money columns stay exact

This one is subtle and worth a moment, because it is the quiet way merged CSV data goes wrong.

A CSV has no types — 19.99 is just four characters. Most tools infer a floating point number, which cannot represent most decimal amounts exactly. Sum a few hundred thousand rows of floating point currency and the total drifts by a cent or two, which is exactly the kind of error that gets noticed by an accountant rather than by you.

Query Streams checks the actual text. When every sampled value in a numeric-looking column is a plain decimal with no more than four digits after the point and no more than fourteen before it, the column is pinned as an exact decimal rather than a float, and the text is parsed directly as a decimal at read time. Totals then add up to the cent.

And it is re-checked on every file, not just the sample. If a later file turns up with a value carrying five decimal places, the connector will not round it to fit — that file parks and names the column. Silent rounding of money is treated as a data error, not a formatting detail.

When one file does not match the others

Folders of exports drift. Someone adds a column in September, a system changes a date format, one file gets saved from a different tool. When a file no longer matches the pinned shape, it is parked: its rows stay out of the table, the reason is recorded, and every other file keeps syncing normally.

The header is checked in advance so the reason is specific. You get “column discount_code is present in the header but not in the pinned table” rather than a column-count mismatch you have to go and diagnose yourself. Duplicate header names, a column that a file used to have and has now dropped, and a truncated final line are all caught the same way.

Which files were held back, and why
SELECT relative_path, detail, occurred_at
FROM   files_events
WHERE  event_type = 'drift'
ORDER  BY occurred_at DESC;

A partially-written file is a special case worth knowing about. If an export is still being appended to when the sync runs, the last line will be incomplete. Rather than ingest the intact rows and leave you wondering why the file looks short, the whole file parks and is picked up complete on the next pass once its size stops changing. A file is therefore always all-in or all-out, never half.

When the folder genuinely holds several layouts

Sometimes the files are supposed to be different. An exports folder might hold orders, refunds and shipments side by side. Rather than forcing them into one shape or making you build three connectors, switch the table layout from pinned to one table per layout. Query Streams groups the files by the columns they actually have and gives each group its own table, up to 25 distinct layouts.

Table names come from the files themselves — a shared filename pattern becomes the table name, so a group of orders_2026_*.csv files lands in a table called orders. Names are fixed the first time they are assigned, so a table your saved queries already reference will not be renamed underneath them.

Per-layout splits the columns, not the dialect. One connector still reads every file with a single delimiter, quote character and encoding, so files that disagree on those remain a refusal even in this mode. A folder mixing comma and semicolon files needs two connectors, or a file pattern that separates them.

Every row remembers which file it came from

This is the thing a merged file loses and you always end up wanting. Combining a thousand CSVs is easy; working out which of the thousand contributed the figure that looks wrong is the hard part.

Every row in a CSV Folder table carries a _source_file column naming the file it came from, and a _row_id that is unique across the whole table and ordered by position within the file. Both are queryable like any other column.

Spot the file that broke the total
SELECT _source_file,
       COUNT(*)     AS row_count,
       SUM(revenue) AS revenue
FROM   sales
GROUP  BY _source_file
ORDER  BY _source_file;

Because the whole folder is one table, cross-file questions become ordinary SQL. Comparing this month against the same month last year is a WHERE clause, not an exercise in opening two workbooks side by side.

Every CSV setting, and when to change it

These are the settings specific to a CSV folder. The ones every folder type shares — root folders, include and exclude patterns, scan interval, hashing, the guard rails and manifest overrides — are documented in the File Set connector guide.

The important thing to understand first: all of these are detected for you on the first sync and then pinned. You set one only to override detection, or to force consistency across a folder that is not quite uniform. Once pinned, a setting is never re-guessed per file — which is exactly why a file that stops matching is parked and reported rather than quietly re-read a different way.

Table name

Required. This is what your combined table is called in SQL — sales, shipments, whatever the folder actually holds. Letters, digits and underscores, not starting with a digit. Pick something meaningful now: it is the name every saved query, Nova question and spreadsheet refresh will use.

Delimiter

Default: a comma. Set it when your files are not actually comma separated — semicolons are near-universal in European exports, tabs are common from database tools, and pipes turn up in mainframe extracts. Type the character itself, so ; or |; for a tab, most exports work with the detection so you rarely need to.

Why you would override rather than let it detect: detection needs the sampled files to agree. If a folder holds a handful of comma files among semicolon ones, detection refuses instead of picking a winner. Setting the delimiter explicitly tells it which is correct, and the odd files out then park with a clear reason rather than blocking the whole connector.

Quote character

Default: a double quote. This is the character wrapped around a field that contains the delimiter — the reason "Smith, John" stays one field. Change it only for the unusual export that uses single quotes. If you are seeing addresses split across columns, this is the setting to look at.

First row is a header

Default: on. Leave it on for anything a human or a reporting tool produced. Turn it off for headerless extracts, where columns become positional instead and you get generic names you can rename with manifest overrides.

Getting this wrong is obvious and harmless: with it wrongly on, your first data row disappears and becomes the column names. With it wrongly off, the real header shows up as a row of text and forces every column to text.

Encoding

Default: auto-detect, which is the right answer almost always — it checks for a byte-order mark, validates strict UTF-8 and falls back to Windows-1252 heuristics, then pins the result. The explicit choices are UTF-8, Windows-1252 (cp1252), UTF-16 LE and Latin-1.

When to override: when detection refuses because the sampled files disagree, and you know which is correct. UTF-16 LE is worth knowing about specifically — it is what Excel writes when you choose “Unicode Text”, and its files start with bytes that look like nothing at all to a naive reader.

One deliberate distinction: Windows-1252 and Latin-1 are not treated as the same thing, because they disagree on the range that holds smart quotes, the euro sign and dashes. Choosing the wrong one of those two turns into a control character rather than raising an error, so pick the one your exporter actually writes.

Null strings

Default: none. One value per line. Every export tool has its own way of writing “no value” — NULL, N/A, NA, -, #N/A, (none) — and without this they arrive as literal text.

Why it matters more than it looks: a single N/A in a numeric column forces the whole column to text, and then SUM() stops working and sorting goes alphabetical. Listing the placeholders here is usually the difference between a numeric column and a text one.

Date format

Default: none — dates are inferred. Set it when day-and-month order is ambiguous, which is the single most damaging silent error in a CSV merge: 03/04/2026 is the third of April or the fourth of March depending on who wrote it, and nothing in the file says which.

Common date format patterns
%Y-%m-%d        2026-08-24
%d/%m/%Y        24/08/2026   (day first - UK, EU)
%m/%d/%Y        08/24/2026   (month first - US)
%d-%b-%Y        24-Aug-2026
%Y%m%d          20260824

The format is pinned like everything else, so a file that stops matching it is parked and reported rather than being re-interpreted with a different reading of the same digits. That is the behaviour you want here — a quietly reversed date is far worse than a file you were told about.

Table layout

Default: one pinned layout, which expects every CSV in scope to share the same columns. Switch to one table per layout when the folder has genuinely accumulated different column sets over time and you want all of them rather than a refusal — each distinct layout gets its own table, up to 25.

Changing this re-samples the folder and rebuilds, by design. Table names already in use are carried across, so existing saved queries keep working.

A setting that does nothing is treated as a bug, not a convenience. An option name the connector does not recognise is rejected outright with the list of names it does accept — because a setting that is silently doing nothing looks exactly like one that is working.

Setting it up

You need a Query Streams account and the Network Agent installed somewhere that can see the folder — a server, a workstation with the share mapped, or your own laptop. CSV Folder connectors require Network Agent 2.6 or newer.

  1. Install the agent from the download page if it is not already running.
  2. In the portal, add a data connector and choose CSV Folder.
  3. Enter the folder path as the agent’s machine sees it. Add a file pattern such as sales_*.csv if the folder holds more than you want combined.
  4. Leave encoding and delimiter on automatic unless you already know the folder is inconsistent.
  5. Save. The agent samples the folder, pins the shape and reports how many files it found and what the columns are.
  6. Open the query builder, pick the connector and query the table — or ask Nova AI to write the SQL for you.
Use the path the agent sees. A drive letter mapped on your own desktop will not resolve on a server running the agent. Use a UNC path such as \\fileserver\exports\sales, or a local path on the agent’s own machine, and check that the account the agent runs under can read it.

Where the combined table can go

  • Microsoft Excel and Google Sheets — run the query from the add-in and the combined rows land in the sheet, refreshed on demand.
  • Airtable, Smartsheet, Baserow, SeaTable and Anvil — scheduled syncs push the combined data into the tool your team already uses.
  • Nova AI — ask a question in plain English and get SQL across every file, with a chart.
  • Claude, Cursor, ChatGPT and Grok — through the Query Streams MCP server, an AI assistant can query the folder directly.
  • REST API — turn the combined table into an endpoint for a partner or an internal application.

And because it is an ordinary connector, the combined CSV table joins to your other data. A folder of shipping exports can be joined to the orders table in PostgreSQL and to Stripe payments in a single read-only statement, with nothing loaded into a warehouse first.

Frequently Asked Questions

How do I combine multiple CSV files into one table? +
Install the Query Streams Network Agent on a machine that can see the folder, add a CSV Folder connector, and give it the folder path plus an optional file pattern like sales_*.csv. Every matching file becomes part of one SQL table. Nothing is merged into a new file — the folder is queried where it sits, so files added later are included automatically.
How many CSV files can be combined at once? +
100,000 files by default, raisable to 2,000,000. Individual files are read up to 512 MB and 2,000,000 rows by default, with higher ceilings available. There is no practical row limit on the combined table of the kind a spreadsheet imposes — you are querying a database engine, not filling cells.
Do all the CSV files need the same columns? +
For the default layout, yes. Query Streams pins one shape and refuses rather than guessing when the sampled files disagree, so you find out immediately instead of discovering later that half your rows are missing. If the folder genuinely holds several kinds of file, switch to one table per layout and each group of similarly-shaped files gets its own table, up to 25 of them.
Can it handle semicolon, tab or pipe-delimited files? +
Yes. The delimiter is detected automatically, along with the quote and escape characters, and you can override the detected value with the Delimiter field if it picks the wrong one. The one requirement is consistency: a single connector reads every file with the same delimiter, so a folder mixing comma and semicolon files needs either two connectors or a file pattern that separates them.
Why do accented characters look wrong when I merge CSVs elsewhere? +
Because most tools assume UTF-8 and many exports are not. Query Streams detects the encoding of each file instead — byte order mark first, then a strict UTF-8 check, falling back to Windows-1252, which is what most BOM-less Windows exports really are. UTF-8, Windows-1252, Latin-1 and both UTF-16 variants are supported, and you can pin one explicitly with encoding.
Will currency values stay accurate? +
Yes. Where every sampled value in a column is a plain decimal with at most four decimal places, the column is pinned as an exact decimal rather than a floating point number, so large sums do not drift by fractions of a cent. Each file is re-checked at read time, and a value that could not be stored exactly parks the file naming the column rather than being rounded silently.
What happens when a new CSV file is added to the folder? +
It joins the table on the next sync with no reconfiguration. Only new and changed files are read, so one new export does not cause the other 49,999 files to be re-parsed. Deleting a file removes its rows from the table, and the removal is recorded in files_events.
Can I tell which file a row came from? +
Every row carries a _source_file column naming its file and a _row_id unique across the table. Grouping by _source_file gives you per-file row counts and totals, which is usually the fastest way to find the one export responsible for a figure that looks wrong.
Are my CSV files uploaded or modified? +
Neither. The files stay where they are and are never written, moved or renamed. Parsed data is cached encrypted on the same machine as the Network Agent, and only the rows a query returns leave your network, over an outbound connection the agent opens itself. Queries are read-only and enforced as such — anything that could write is rejected before it runs.

Get Started

Stop merging CSV files by hand

Point the agent at the folder once and query every export as a single table — from Microsoft Excel, Google Sheets, Airtable or your AI assistant. New files join on their own, and your data never leaves your network.

Related guides: How to query a folder of files with SQL | Download the Query Streams Agent | All File Set Connector guides

Category: File Set Connectors

Tags: combine csv files, merge csv files, combine multiple csv files into one, csv folder connector, query csv with sql, csv to excel, csv encoding

Meta Description: Combine multiple CSV files into one live SQL table. No merging, no uploads, new files join automatically.

Updated on August 27, 2026

Powered by BetterDocs