Output a header label in data field in miller
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
Given file.csv:
a,b,c
1,2,3
How can mlr
be made to output:
a,b,c
1,2,c
Using the label name of $c
without knowing in advance that it's the letter "c"?
Note: correct answer must use mlr
only.
linux text-processing miller
add a comment |Â
up vote
1
down vote
favorite
Given file.csv:
a,b,c
1,2,3
How can mlr
be made to output:
a,b,c
1,2,c
Using the label name of $c
without knowing in advance that it's the letter "c"?
Note: correct answer must use mlr
only.
linux text-processing miller
do you want the last header column to be the last column value or all other records?
â RomanPerekhrest
Mar 14 at 15:35
@RomanPerekhrest, In this simplest possible case either way would be fine.
â agc
Mar 14 at 15:37
I hadn't come across miller -mlr
- before - looks great, will have to spend some time playing with it and reading the docs. Thanks for the link.
â cas
Mar 15 at 6:14
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
Given file.csv:
a,b,c
1,2,3
How can mlr
be made to output:
a,b,c
1,2,c
Using the label name of $c
without knowing in advance that it's the letter "c"?
Note: correct answer must use mlr
only.
linux text-processing miller
Given file.csv:
a,b,c
1,2,3
How can mlr
be made to output:
a,b,c
1,2,c
Using the label name of $c
without knowing in advance that it's the letter "c"?
Note: correct answer must use mlr
only.
linux text-processing miller
edited Mar 14 at 15:43
asked Mar 14 at 15:31
agc
4,0391935
4,0391935
do you want the last header column to be the last column value or all other records?
â RomanPerekhrest
Mar 14 at 15:35
@RomanPerekhrest, In this simplest possible case either way would be fine.
â agc
Mar 14 at 15:37
I hadn't come across miller -mlr
- before - looks great, will have to spend some time playing with it and reading the docs. Thanks for the link.
â cas
Mar 15 at 6:14
add a comment |Â
do you want the last header column to be the last column value or all other records?
â RomanPerekhrest
Mar 14 at 15:35
@RomanPerekhrest, In this simplest possible case either way would be fine.
â agc
Mar 14 at 15:37
I hadn't come across miller -mlr
- before - looks great, will have to spend some time playing with it and reading the docs. Thanks for the link.
â cas
Mar 15 at 6:14
do you want the last header column to be the last column value or all other records?
â RomanPerekhrest
Mar 14 at 15:35
do you want the last header column to be the last column value or all other records?
â RomanPerekhrest
Mar 14 at 15:35
@RomanPerekhrest, In this simplest possible case either way would be fine.
â agc
Mar 14 at 15:37
@RomanPerekhrest, In this simplest possible case either way would be fine.
â agc
Mar 14 at 15:37
I hadn't come across miller -
mlr
- before - looks great, will have to spend some time playing with it and reading the docs. Thanks for the link.â cas
Mar 15 at 6:14
I hadn't come across miller -
mlr
- before - looks great, will have to spend some time playing with it and reading the docs. Thanks for the link.â cas
Mar 15 at 6:14
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
Simply with awk
:
awk 'BEGIN FS=OFS="," (NR == 1)? c=$NF : $NF=c 1' file.csv
Sample output:
a,b,c
1,2,c
Thanks & sorry -- I'm at fault for not specifying that amlr
-only answer is required. (I'm trying to learnmlr
, but it can be puzzling.) Q. revised to reflect language limitation. +1 because it works tho'...
â agc
Mar 14 at 15:47
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Simply with awk
:
awk 'BEGIN FS=OFS="," (NR == 1)? c=$NF : $NF=c 1' file.csv
Sample output:
a,b,c
1,2,c
Thanks & sorry -- I'm at fault for not specifying that amlr
-only answer is required. (I'm trying to learnmlr
, but it can be puzzling.) Q. revised to reflect language limitation. +1 because it works tho'...
â agc
Mar 14 at 15:47
add a comment |Â
up vote
1
down vote
Simply with awk
:
awk 'BEGIN FS=OFS="," (NR == 1)? c=$NF : $NF=c 1' file.csv
Sample output:
a,b,c
1,2,c
Thanks & sorry -- I'm at fault for not specifying that amlr
-only answer is required. (I'm trying to learnmlr
, but it can be puzzling.) Q. revised to reflect language limitation. +1 because it works tho'...
â agc
Mar 14 at 15:47
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Simply with awk
:
awk 'BEGIN FS=OFS="," (NR == 1)? c=$NF : $NF=c 1' file.csv
Sample output:
a,b,c
1,2,c
Simply with awk
:
awk 'BEGIN FS=OFS="," (NR == 1)? c=$NF : $NF=c 1' file.csv
Sample output:
a,b,c
1,2,c
answered Mar 14 at 15:40
RomanPerekhrest
22.4k12144
22.4k12144
Thanks & sorry -- I'm at fault for not specifying that amlr
-only answer is required. (I'm trying to learnmlr
, but it can be puzzling.) Q. revised to reflect language limitation. +1 because it works tho'...
â agc
Mar 14 at 15:47
add a comment |Â
Thanks & sorry -- I'm at fault for not specifying that amlr
-only answer is required. (I'm trying to learnmlr
, but it can be puzzling.) Q. revised to reflect language limitation. +1 because it works tho'...
â agc
Mar 14 at 15:47
Thanks & sorry -- I'm at fault for not specifying that a
mlr
-only answer is required. (I'm trying to learn mlr
, but it can be puzzling.) Q. revised to reflect language limitation. +1 because it works tho'...â agc
Mar 14 at 15:47
Thanks & sorry -- I'm at fault for not specifying that a
mlr
-only answer is required. (I'm trying to learn mlr
, but it can be puzzling.) Q. revised to reflect language limitation. +1 because it works tho'...â agc
Mar 14 at 15:47
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f430199%2foutput-a-header-label-in-data-field-in-miller%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
do you want the last header column to be the last column value or all other records?
â RomanPerekhrest
Mar 14 at 15:35
@RomanPerekhrest, In this simplest possible case either way would be fine.
â agc
Mar 14 at 15:37
I hadn't come across miller -
mlr
- before - looks great, will have to spend some time playing with it and reading the docs. Thanks for the link.â cas
Mar 15 at 6:14