mergefile.m – a MatLab script to merge CSV files

35 sec read

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

Download mergefile.m



写作助手,把中式英语变成专业英文


Want to receive new post notification? 有新文章通知我

采用基于频率簇(Cluster)的置换检验(Permutation)方法选取感兴趣频段

作者:北京师范大学 龙宇航,[email protected]代码来源(见本页底部):周思远 在使用wtc计算脑间神经同步后,我们需要在多个频率段、多个通道组合上对神经同步值进行统计检验,因
Xu Cui
1 min read

Calculate phase difference between two general signals (e.g. HbO…

In a recent fNIRS journal club (vedio recorded here), Dr. Tong talked about their work on the phase difference between oxy and deoxy Hb, and its relationship with participants’ age. This article is a demo of how to use Hilbert transform to calc
Xu Cui
1 min read

nirs2img, create an image file from NIRS data

Update 2021/2/27: If you find griddata3 not working, try to change griddata3 to griddata. I was asked where to get nirs2img script. Here it is. The download link is at the bottom of this article. nirs2img is to create an image file from the input dat
Xu Cui
51 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *