Last active
June 8, 2017 11:36
-
-
Save TooDumbForAName/8bb45e115a0ccf9d3fb1fcf86bca181d to your computer and use it in GitHub Desktop.
Basic CSV to HTML converter
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
#!/bin/bash | |
FILENAME=$1 | |
if [ "$FILENAME" == "" ]; | |
then | |
printf "%s\n" "Please specify the name of the CSV file to convert:" | |
read FILENAME | |
fi | |
IFILE=$FILENAME.copy | |
cp $FILENAME $IFILE | |
sed -i 's|,|</TH><TH>|g' $IFILE | |
sed -i 's|^|<TR><TH>|g' $IFILE | |
sed -i 's|$|</TH></TR>|g' $IFILE | |
#begin basic HTML document | |
touch header.html | |
printf "%s\n" "<HTML>" >> header.html | |
printf "%s\n" "<HEAD>" >> header.html | |
printf "%s\n" "<TITLE></TITLE>" >> header.html | |
printf "%s\n" "</HEAD>" >> header.html | |
printf "%s\n" "<BODY>" >> header.html | |
printf "%s\n" "<TABLE>" >> header.html | |
cat header.html $IFILE > csv.html | |
rm $IFILE | |
rm header.html | |
printf "\n%s\n" "</TABLE>" >> csv.html | |
printf "%s\n" "</BODY>" >> csv.html | |
printf "%s\n" "</HTML>" >> csv.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wrote this in like 10 minutes as an example for someone on Yahoo Answers. It's obviously terrible in several ways, but if you want it, you can have it. I have no use for such a thing.