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
Receive email notification via email 博客有新内容通知我
Don't want to miss new papers in your field? Check out Stork we developed: ![]() |
专注医学生物类的论文润色 联系他们请用优惠码 STORK4,他们会给你折扣。 |