Horizontally Combine Many CSV Sheets in Google Sheets

An odd request came in from a faculty member the other day. As part of their research they had 60 or so CSVs that they wanted combined horizontally. I have many ways to do it vertically but this was a new one. Each file was around 350KB so they weren’t huge and 60 isn’t a ton but it’d be a hassle to do by hand and ripe for accidents. I Googled a bit. Saw some stuff using PHP and array_merge, saw some people using Pandas in Python.1 I talked to Jeff and he mentioned uploading them to MySQL and then doing a join off the common ids. All good and reasonable paths but they just didn’t seem like things I wanted to do. I then saw that Amit2 had a script for importing CSVs into Google Sheets. His import wasn’t meant to do quite what we were doing but it gave me enough momentum to create the script below. The first function3, just loops through all the files in a folder you indicate through the folder ID. It calls the second function which imports the CSVs. The key was changing the first line to the second. It takes a bit to run. The first time it got through maybe 45 sheets before Google got upset about how many cells I’d […]