loop through markdown tables

Note

using miller and fish, quickly loop through a markdown table and interact with each row programmatically

Files

loop-through-markdown-table.fish
fish
#!/usr/bin/env fish

set md /path/to/file/with/markdown-table.md

# use miller (https://github.com/johnkerl/miller) to parse markdown tables
# this pattern can be adapted to csv, tsv and other tabular formats that miller supports

mlr --imd cat $md | while read -l line
  set column1 (echo $line | awk -F, '{split($1, a, "="); print a[2]}')
  set column2 (echo $line | awk -F, '{split($2, a, "="); print a[2]}')
  set column3 (echo $line | awk -F, '{split($3, a, "="); print a[2]}')

  # some shell operation involving $column(1,2,3)
end