Skip to content

Daily

Merge daily CSV exports in Drive into one clean master file

Each evening the day's CSV exports are combined into one deduplicated file in Drive, and your team sees row counts and problems in Slack.

Runs
Daily
Apps
Google Drive, Slack
AI
Not needed
Access
Drive read+write; Slack chat:write

Send this to your assistant

Create a ClickRuntime automation: every evening, combine the CSVs in my Drive 'Exports' folder into one deduplicated master CSV, save it, and post the row counts and any problem rows to #ops.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

An operations coordinator receives CSV exports from three systems every day: the web shop, the warehouse and the payment processor. Before anyone can report on the day, she opens each file, copies rows into one sheet, removes duplicates and hunts for rows with missing order numbers. It takes most of an hour and the result depends on how careful she was that day.

This automation does the merge every evening the same way. It keeps one master file in Drive, sets aside rows that fail basic checks, and tells the team in Slack how many rows came in and what needs a look.

What you get out of it

  • One file everyone can trust

    Reports, dashboards and finance all start from the same master file instead of personal copies. Fewer versions means fewer arguments about whose numbers are right.

  • Duplicates removed the same way every day

    Rows that appear in more than one export are kept once, by a fixed rule. Manual cleaning drifts from person to person; this does not.

  • Problem rows are set aside, not lost

    Rows missing key fields go into a separate file, so they can be fixed without polluting the master or being silently dropped.

  • A daily check you can see

    The Slack recap shows row counts per file. A sudden drop to zero tells you an export broke before anyone builds a report on bad data.

How it works

What happens, step by step

  1. Every evening ClickRuntime looks in your Drive 'Exports' folder for CSV files added that day.

  2. It combines them into one table, matching columns by their headers.

  3. Rows with the same order number are kept once, and rows missing required fields are set aside in a separate file.

  4. The master file and the set-aside file are saved to Drive, and a recap with row counts is posted in your #ops Slack channel.

Before it runs live

  • Connect Google Drive
  • Connect Slack, then invite the app to the channel (type /invite @ClickRuntime there)

What you get

RunsDaily
Merge daily CSV exports in Drive into one clean master filetoday, 9:00Succeeded
Slack · #opsCSV recap: shop.csv 412, warehouse.csv 398, payments.csv 405. Master 801 rows, 6 set aside for missing order IDs.

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Run it at a different time, more or less often, or only on weekdays
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Google Sheets
  • Combine it with other Google Drive and Slack steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
daily_csv_reconciliation_with_slack_recap.pyexample
import csv, io
from datetime import date
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from googleapiclient.http import MediaInMemoryUpload
from clickruntime import on_trigger, credentials, notify
FOLDER_ID = "your-exports-folder-id"
KEY = "order_id"

@on_trigger
def run(event):
    drive = build("drive", "v3", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    q = f"'{FOLDER_ID}' in parents and mimeType='text/csv' and createdTime > '{date.today().isoformat()}T00:00:00'"
    files = drive.files().list(q=q, fields="files(id,name)").execute().get("files", [])
    seen, good, bad, counts = set(), [], [], []
    for f in files:
        rows = list(csv.DictReader(io.StringIO(drive.files().get_media(fileId=f["id"]).execute().decode())))
        counts.append(f"{f['name']}: {len(rows)}")
        for r in rows:
            if not r.get(KEY):
                bad.append(r)
            elif r[KEY] not in seen:
                seen.add(r[KEY]); good.append(r)
    for name, rows in ((f"master-{date.today()}.csv", good), (f"quarantine-{date.today()}.csv", bad)):
        if rows:
            buf = io.StringIO(); w = csv.DictWriter(buf, fieldnames=list(rows[0])); w.writeheader(); w.writerows(rows)
            drive.files().create(body={"name": name, "parents": [FOLDER_ID]},
                                 media_body=MediaInMemoryUpload(buf.getvalue().encode(), mimetype="text/csv")).execute()
    notify.slack(f"CSV recap: {', '.join(counts) or 'no files'}. Master {len(good)} rows, {len(bad)} set aside.", channel="#ops")
    return {"files": len(files), "rows": len(good), "set_aside": len(bad)}

FAQ

Common questions

Which column is used to spot duplicates?
You choose the key, such as an order number or transaction ID. Rows with the same key are treated as one, and the first copy is kept.
What happens to the original CSV files?
They stay where they are in the Exports folder. The master and set-aside files are saved alongside them, so you can always check against the source.
Can the files have different column orders?
Yes, as long as they share the same column names. Columns are matched by header name, not by position.
What permissions does it need?
Drive read+write; Slack chat:write. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (daily). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Merge daily CSV exports in Drive into one clean master file” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.