Last active
December 14, 2018 01:26
-
-
Save pddg/d2fb638dda865e4a4438524ff123cf44 to your computer and use it in GitHub Desktop.
https://github.com/monochromegane/mdt を使ってcsvをmdのtableに変換するfishの関数(gzip対応版)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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