I have ~100 CSV files that I want to combine into one single Excel spreadsheet (everything in one tab, not in separate tabs). These CSV files are identical in format: each contains 4,000 rows and 2 columns with header, about 60 KB in size.
All solutions I've found so far append the next CSV at the end of the last row of the active tab. I haven't seen one that can append new CSVs to the columns immediate to the right of last column.
Here're some examples.
DOS copy method: copy *.csv merge.txt
This solution. (VBA script.)
Using Excel's Data>New Query>From File>From Folder (Excel 2013) .
There are also examples with Windows Powershell scripts to merge CSV files on the internet.
All of the above create a single Excel spreadsheet with about 400,000 rows of data, which is useless to me.
I'd appreciate suggestions to solve this problem. Thanks!
Edit. An easy solution is found: using r's cbind() to combine the data in a data frame and then write it to a csv. The entire process took ~3 seconds. Right tool for the job!
Thanks to everyone for contributing. Cheers,
--tcollar
nextColumn = .Range("A1").SpecialCells(xlCellTypeLastCell).Column + 1