3.20 mduprec - Duplicate Record

Duplicate each record. Specify the number of rows to duplicate at n=, and duplicate records based on the field specified at f= parameter.

Format

mduprec f=|n= [i=] [o=] [-nfn] [-nfno] [-x] [--help] [--version]

Parameters

f=

Duplicate records based on the values in the field name.

 

Duplicate the number of rows for each record based on the numeric values in the column.

n=

Number of records to duplicate

 

Specify the number of rows to duplicate for each record.

Examples

Example 1: Basic Example

Generate multiple records of the data based on the numeric value in the “Quantity” field. Records containing NULL values will not be duplicated.

$ more dat1.csv
store,val
A,2
B,
C,5
$ mduprec f=val i=dat1.csv o=rsl1.csv
#END# kgduprec f=val i=dat1.csv o=rsl1.csv
$ more rsl1.csv
store,val
A,2
A,2
C,5
C,5
C,5
C,5
C,5

Example 2: Define the number of rows to duplicate

Duplicate two rows (n=2) for each record in the dataset.

$ mduprec n=2 i=dat1.csv o=rsl2.csv
#END# kgduprec i=dat1.csv n=2 o=rsl2.csv
$ more rsl2.csv
store,val
A,2
A,2
B,
B,
C,5
C,5

Related Commands

mcount : Reverse the operation of mduprec.

mwindow : Copy and shift a specified number of records.