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.
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
Every evening ClickRuntime looks in your Drive 'Exports' folder for CSV files added that day.
It combines them into one table, matching columns by their headers.
Rows with the same order number are kept once, and rows missing required fields are set aside in a separate file.
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
Build your own
Need it to work differently?
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
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?
What happens to the original CSV files?
Can the files have different column orders?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Get a weekly Drive cleanup report in Slack
Every Monday you see the duplicate files, old backups and long-untouched files in your Drive, so cleanup takes minutes.
See how it worksFile new invoices in Drive and tell finance in Slack
Every invoice that arrives by email lands in your Drive Invoices folder, and #finance gets a daily list with links.
See how it worksWrite a weekly AI brief, save it as a PDF in Drive and share it in Slack
Every Monday a written brief from your notes lands in Drive as a PDF, with the link posted in your Slack channel.
See how it worksKeep exploring
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.