Skip to content

cut and regex: why doesn't this example work? #764

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

You must be logged in to vote

@aborruso sorry for the delay!!

The confusion is because:

  • On input the field name is @graph
  • On output the field names (flattened) are @graph.1.@id through @graph.4.iterAmministrativoAttivo
  • Flatten happens, by default, the very last step before output
  • The cut operates on the input field name not the output field names

This should probably be made clearer somehow:

  • mlr cut --help
  • Some examples in the webdocs

As for how to do the cut you want: you can flatten before cut

mlr --from input.json --j2x flatten then cut -r -f '^@graph.1.*'
@graph.1.@id                      impresa:LgU0qvE+USpLWpu+dbQePfm7KJfG8SOgr/YdHGlu9VI=
@graph.1.@type                    impresa
@graph.1.idBene             …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by aborruso
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