3.50 msep - Partition Records

Define the file name and location the save the separate records at the d= parameter. Since it is possible to embed the ${fieldname} in the file name specified, as a result, the data can be split into separate files for corresponding fields. For example, the argument d=./out/${date}.csv specifies the out directory in the current directory, and the file is created from corresponding values in the date field.

Format

msep d= [-p] [i=] [-nfn] [-nfno] [-x] [-q] [--help] [--version]

Parameters

d=

Specify the field name used for splitting to different data files.

 

String specify here will be added as file name for each record.

 

Embed field name as ${field name}.

-p

Create the new directory name specify at the d= parameter which does not currently exist.

Examples

Example 1: Basic Example

Create a directory named dat, and separate the data according to the date value in the directory.

$ more dat1.csv
item,date,quantity,price
A,20081201,1,10
B,20081201,4,40
A,20081202,2,20
A,20081203,3,30
B,20081203,5,50
$ msep d='./dat/${date}.csv' -p i=dat1.csv
#END# kgsep -p d=./dat/${date}.csv i=dat1.csv
$ ls ./dat
20081201.csv
20081202.csv
20081203.csv
$ more ./dat/20081201.csv
item,date%0,quantity,price
A,20081201,1,10
B,20081201,4,40
$ more ./dat/20081202.csv
item,date%0,quantity,price
A,20081202,2,20
$ more ./dat/20081203.csv
item,date%0,quantity,price
A,20081203,3,30
B,20081203,5,50
$ more ./dat/B.csv
./dat/B.csv: No such file or directory

Related Commands

msep2 : While the functionality is similar with msep, serial number is used to name the output file, and prints a list of corresponding key and file name to a separate file.

mcat : This command restore and merge all the partitioned files by sep to the original file.