Skip to content

Instantly share code, notes, and snippets.

@bpwebs
Created November 13, 2023 00:52
Show Gist options
  • Save bpwebs/991beff47882cb264625793e22a993d3 to your computer and use it in GitHub Desktop.
Save bpwebs/991beff47882cb264625793e22a993d3 to your computer and use it in GitHub Desktop.
Combine CSV files with Google Apps Script
function combineCsv() {
const folder = DriveApp.getFolderById("1MBaI_rGJ6t_loANMAvGpDbr2MeHZwxnn");
const files = folder.getFilesByType(MimeType.CSV);
let combinedData = [];
while(files.hasNext()){
let file = files.next();
let csvData = Utilities.parseCsv(file.getBlob().getDataAsString());
combinedData = combinedData.concat(csvData);
}
folder.createFile("Combined.csv", combinedData.join("\n"),MimeType.CSV);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment