Skip to content

Instantly share code, notes, and snippets.

@ogaida
Created June 1, 2024 13:49
Show Gist options
  • Save ogaida/99d610a08af0093fa9fbf8b1c0619ed1 to your computer and use it in GitHub Desktop.
Save ogaida/99d610a08af0093fa9fbf8b1c0619ed1 to your computer and use it in GitHub Desktop.
csv preview with fzf
#!/usr/bin/env bash
file=$1
iconv --from-code=ISO-8859-1 --to-code=UTF-8 $file | \
mlr --icsv --ifs ';' --omd cat| \
fzf -e -i --preview="echo {}|tr '|' '\n'" -m --bind ctrl-o:select-all | \
awk -F'|' '{sum += $9}END{print sum}'
# requirements: mlr (miller), fzf (fuzzy finder), iconv (convert codesets)
# it filters lines from csv
# converts to markdown table
# by spressing ctrl-o it will select all matching lines
# at the end calculates the total of column 8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment