Skip to content

How to check in the DSL whether a column exists #1036

Answered by aborruso
halloleo asked this question in Q&A
Discussion options

You must be logged in to vote

@halloleo I'm cloning a reply to map a "right" answer.

To check for column existence in the DSL, you could use is_present function:

mlr -N --csv put 'if(NR==1) { if(!is_present($3)) { $[3]="comment" } }' input.csv

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@halloleo
Comment options

@aborruso
Comment options

@halloleo
Comment options

@halloleo
Comment options

Comment options

You must be logged in to vote
1 reply
@halloleo
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by halloleo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants