Skip to content

Instantly share code, notes, and snippets.

@pddg
Last active December 14, 2018 01:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pddg/d2fb638dda865e4a4438524ff123cf44 to your computer and use it in GitHub Desktop.
Save pddg/d2fb638dda865e4a4438524ff123cf44 to your computer and use it in GitHub Desktop.
https://github.com/monochromegane/mdt を使ってcsvをmdのtableに変換するfishの関数(gzip対応版)
function csv2md
function usage
echo "Description: Convert csv file to table in markdown format."
echo "Usage: csv2md [-z] FILE"
echo "Options and arguments:"
echo -e "\t-z\t: Uncompress gzip archived csv"
echo -e "\tFILE\t: Path to CSV file"
end
set command "cat"
for opt in $argv
switch "$opt"
case -z
set command "gunzip -c"
case -h
usage
return 0
case **
set csv "$opt"
end
end
if not string length -q "$csv"
echo "Please specify csv file to convert"
usage
return 1
end
eval $command $csv | mdt
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment