Last active
August 29, 2015 14:03
-
-
Save mikkun/ee94abe9489d6338c9a9 to your computer and use it in GitHub Desktop.
CSVファイルからHTMLの表を作るシェルスクリプト(試作品)
This file contains hidden or 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
#!/usr/bin/env bash | |
echo '<!DOCTYPE html>' > out.html | |
echo '<html><body><table border="1">' >> out.html | |
cat in.csv | | |
sed -e 's/^"""/"”/g' -e 's/,"""/,"”/g' | | |
sed -e 's/"""$/”"/g' -e 's/""",/”",/g' | | |
sed -e 's/""/”/g' | | |
tr ' ' '\a' | | |
tr ',' ' ' | | |
while read line ; do | |
echo '<tr>' >> out.html | |
echo "$line" | | |
xargs -n 1 echo | | |
sed 's/^\(.*\)$/\a\a<td>\1<\/td>/' | | |
tr ' ' ',' | | |
tr '\a' ' ' >> out.html | |
echo '</tr>' >> out.html | |
done | |
echo '</table></body></html>' >> out.html | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment