Script to Merge All Csv Files to One File.

For example I have file structure like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
├── 2013-01  
│   ├── 2013-01-avon-and-somerset-street.csv  
├── 2013-02  
│   ├── 2013-02-avon-and-somerset-street.csv  
├── 2013-03  
│   ├── 2013-03-avon-and-somerset-street.csv  
├── 2013-04  
│   ├── 2013-04-avon-and-somerset-street.csv  
├── 2013-05  
│   ├── 2013-05-avon-and-somerset-street.csv  
├── 2013-06  
│   ├── 2013-06-avon-and-somerset-street.csv  
└── 2013-07  
├── 2013-07-avon-and-somerset-street.csv

To process multiple files in R or Pandas would be a pain, if I could combine all the csv in every folder into one file and I can work on just that one file.

How to use it’s really easy. Just copy the source code and paste in anywhere. For example, I would call this **merge_csv</code>. Then you would execute like this.</p>

1
sh merge_csv <FOLDER_YOU_WANT>

The script will iterate to every folder and sub-folder.

Update
I also got this from my friend, which is much shorted. I really need to improve my shell script.

Sep 16th, 2013

Comments