Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documentation for syntax to extract two or more fields from same "record" ? #108

Closed
mfioretti opened this issue Aug 5, 2023 · 1 comment

Comments

@mfioretti
Copy link

Greetings,

I am learning Xidel 0.9.8 on Ubuntu. My issue is that I have looked into the documentation, but as far as I can tell it gives no clue (none I recognize, at least) to do this.

I have a JSON file with records that have, among others, id and title fields, eg:

#> jq '.' test.json  | cut -c1-100 | more
[
  {
    "id": 42,
    "title": "Software is eating the world",

I want to extract with Xidel those two values, producing output lines like this:

ARTICLE: 42 ==> Software is eating the world

or at least like this:

42 ==> Software is eating the world

and I can't find, or recognize, the right syntax to use for what seems a general, very common need to me. The closest I have come to what I want is this:

xidel test.json -e 'for $t in $json/title return string-join(("$t/../id", $t), " ==> ")'

which produces lines like these:

$t/../id ==> Software is eating the world

what is the right way to refer to the id value of the current record???

Thanks!

@Reino17
Copy link

Reino17 commented Aug 5, 2023

Please see the mailinglist for my reply.

@benibela benibela closed this as completed Mar 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants