My wife asked me to write a script to merge some csv files she has. Usually this can be accomplished by a simple command in Mac or Linux:
cat *.csv >all0.csv
In Windows, it is:
copy *.csv all0.csv
But my wife needs more. She wanted the merged file have a column indicating the name of the source file. So I have to write a MatLab script, called mergefile.m. Here is the description.
mergefile merge csv files in a directory to all0.csv mergefile merges the content of all the csv files in a directory into a single file all0.csv. It also adds a column indicating the original file name. It assumes the files to be merged have the same header, and only the header of the first file will be kept (i.e. the first row of the files - except for the 1st file, will be ignored). Author: Xu Cui (https://www.alivelearn.net/) 2018-10-10