Add specified string as new field(s) in all rows. More than one fields can be added.
msetstr v= a= [i=] [o=] [-nfn] [-nfno] [-x] [--help] [--version]
v= List of character strings to add. NULL value is added if the value is not specified. a= Add field name. The number of string and field name of specified at v= must be the same number. v=.
Calculate the date by setting a reference date (defined as January 01, 2007) and add the string “20070101” in all lines and save the output as a new column named “ReferenceDate”.
$ more dat1.csv customer,date A,20081202 A,20081204 B,20081203 $ msetstr v=20070101 a=ReferenceDate i=dat1.csv o=rsl1.csv #END# kgsetstr a=ReferenceDate i=dat1.csv o=rsl1.csv v=20070101 $ more rsl1.csv customer,date,ReferenceDate A,20081202,20070101 A,20081204,20070101 B,20081203,20070101
$ msetstr v=20070101,20070201 a=RefDate1,RefDate2 i=dat1.csv o=rsl2.csv #END# kgsetstr a=RefDate1,RefDate2 i=dat1.csv o=rsl2.csv v=20070101,20070201 $ more rsl2.csv customer,date,RefDate1,RefDate2 A,20081202,20070101,20070201 A,20081204,20070101,20070201 B,20081203,20070101,20070201
$ msetstr v= a=NewColumn i=dat1.csv o=rsl3.csv #END# kgsetstr a=NewColumn i=dat1.csv o=rsl3.csv v= $ more rsl3.csv customer,date,NewColumn A,20081202, A,20081204, B,20081203,
mcal : Use the if function to add a fixed string according to differently conditions for each row.