Csv2html bash function

From Bitbull Wiki
Revision as of 15:34, 15 September 2017 by Chris (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
# csv2html csv-file.csv
csv2html(){
   CSV=$1
   echo '<Table border="1">'
   while read line
   do
      echo "<tr>"
         for word in $(echo $line | tr ' ' '§' | tr ';' ' ')
          do
             echo "<td nowrap >$(echo "$word" | tr '§' ' ' | sed 's/ /\ /g' )</td>"
          done
      echo "</tr>"
   done <$CSV
   echo "</table>" 
   }