Extract a specific row from a table
Goal: Pull a single row out of a Markdown table by its position.
Prerequisites: None.
Query
.[2][]
$ mq '.[2][]' README.md
Input
| Name | Age | City |
| ----- | --- | ---- |
| Alice | 30 | NYC |
| Bob | 25 | LA |
Output
| Bob | 25 | LA |
Notes
- Row indexing starts at the header: index
0is the header row,1is the first data row (Alice),2is the second (Bob). - To get the cells as plain text instead of a rendered row, pipe through
to_text:mq '.[2][] | to_text' README.mdprintsBob,25,LAon separate lines.-F jsondumps the full node structure (position info and all), not just the values, so it’s rarely what you want here. - Need the row as a keyed record instead (
{"Name": "Bob", "Age": "25", "City": "LA"})? See Extract all tables from a document and usetable::to_array, which returns rows in that shape without the header-offset indexing above.