# This program is to help you translate SQL # to HTML for display on the Web. # If you have a file named mercury.txt that looks like this ... # "Freedom 7", "5/5/1961", "5/5/1961", "sub-orbital" # "Liberty Bell 7", "7/21/1961", "7/21/1961", "sub-orbital" # "Friendship 7", "2/20/1962", "2/20/1962", "earth orbit" # "Aurora 7", "5/24/1962", "5/24/1962", "earth orbit" # "Sigma 7", "10/3/1962", "10/3/1962", "earth orbit" # "Faith 7", "5/15/1963", "5/15/1963", "earth orbit" # and if you also have a file named mercury.awk that looks like this ... # # This is an Awk program for reformatting # # the mercury.txt file. # # # # Put yourself in a folder that contains # # both mercury.awk and mercury.txt. # # # # Run this program by typing: # # awk -f mercury.awk mercury.txt # BEGIN { # # specify the field separator in the input. # FS=", "; # # specify the field separator in the output. # OFS=","; # } # { # # replace double quotation marks around the # # name of the spacecraft with single quotes # spacecraft = "'" substr( $1, 2, length($1) - 2 ) "'"; # # launchDay = substr( $2, 2, length($2) - 2 ); # # divide the date into 3 parts: month, day, and year # split( launchDay, launch, "/" ); # # reassemble the parts of the date in the order # # that SQL requires # # at the same time, replace double quotation marks around the # # launch date with single quotes # takeOff = "'" launch[3] "-" launch[1] "-" launch[2] "'"; # # recoveryDay = substr( $3, 2, length($3) - 2 ); # # divide the date into 3 parts: month, day, and year # split( recoveryDay, recovery, "/" ); # # reassemble the parts of the date in the order # # that SQL requires # # at the same time, replace double quotation marks around the # # recovery date with single quotes # splashDown = "'" recovery[3] "-" recovery[1] "-" recovery[2] "'"; # # # replace double quotation marks around the # # name of the destination with single quotes # destination = "'" substr( $4, 2, length($4) - 2 ) "'"; # # print "(" spacecraft, takeOff, splashDown, destination "),"; # } # Then you can make a file named mercury.sql like this ... # awk -f mercury.awk mercury.txt > mercury.sql # Now you have a file named mercury.sql that looks like this ... # ('Freedom 7','1961-5-5','1961-5-5','sub-orbital'), # ('Liberty Bell 7','1961-7-21','1961-7-21','sub-orbital'), # ('Friendship 7','1962-2-20','1962-2-20','earth orbit'), # ('Aurora 7','1962-5-24','1962-5-24','earth orbit'), # ('Sigma 7','1962-10-3','1962-10-3','earth orbit'), # ('Faith 7','1963-5-15','1963-5-15','earth orbit'), # You can now created a file named mercury.html like this ... # run this program as follows: # sed "s/[()']//g" mercury.sql | sed "s/,$//" | awk -f table.awk > mercury.html # Now, open mercury.html in a browser. BEGIN { print "" print "" print "" print "" print "My reviews" print "" print "" print "" print "" print "

" print "Your Name" print "

" print "
" print "
" print "\t\t" print "
" print "
" print "\t\t" print "
" print "
" print "\t\t" print "
" print "
" print "\t\t" print "
" print "\t\t" print "
\n" print "
" print "
" print "\t\t" print "
" print "
" print "\t\t" print "
" print "
" print "\t\t" print "
" print "
" print "\t\t" print "
" print "\t\t" print "
\n" print "
" print "
" print "\t\t" print "
" print "
" print "\t\t" print "
" print "
" print "\t\t" print "
" print "
" print "\t\t" print "
" print "\t\t" print "
\n" print "
" print "
" print "\t\t" print "
" print "
" print "\t\t" print "
" print "\t\t" print "
" print "
" print "
" print "\t\t" print "
" print "\t\t" print "
\n" print "" FS="," } { print "\t" # if the number of rows in your table is # something other than 4, then you will have # make a change here ... print "\t\t" print "\t\t" print "\t\t" print "\t\t" print "\t" } END { print "
" $1 "" $2 "" $3 "" $4 "
" print "" print "" }