title: merge html code with .csv file
body: <p>I have a spec file that looks like this <code>"PC DELL OptiPlex 3010MT i3 3220/2GB/500GB/DVD-RW/FREE DOS / 5Y NBD<br>
  Intel i3 3220 (Dual Core, 3.30GHz, 3MB, w/ HD2500 Graphics), 2GB (1x2GB) DDR3 PC3-1600MHz, 500GB HDD SATA III 7200rpm, DVD+/-RW (16x), FREE DOS, Warranty: 5Yr Basic Warranty NBD on site"</code></p>
  
  <p>So I need to populate an html table and then put it in a .csv file for uploading
  So far I have managed to "clean" the file with the following script</p>
  
  <pre><code> for f in $(ls *.csv)
   do
   #fix newline from file
   sed -i ':a;{N;s/NBD   \n/NBD,/};ba;s/"//g;' "$f" 
  
   #fix csv &amp; and remove strings
   sed -i 's/"PC/PC/g;s/Core\,/Core/g;s/3\,/3./g;s/3MB\,//g;s/6MB\,//g;s/6MB//g;s/w   \///g;s/7,200/7200/g;s/site\"/site/g;s/3MB//g;s/3\,/3\./g;s/w\///g;s/3\,/3\./g;s/Cache\,)/Cache/g;s/ Internal Dell Business Audio Speaker\,//g;' "$f"
  
  #don't know how to remove symbols with sed using awk
  awk 'NR==FNR {a[$1]=$2;next} {for ( i in a) gsub(i,a[i])}1' template $f &gt;temp.txt
  mv temp.txt $f
  done
  </code></pre>
  
  <p>And then using this script to populate the html table</p>
  
  <pre><code>#!/bin/bash
  
  for f in $(ls *.csv)
  do
  #split csv into 1line .csv files
  split --additional-suffix=.csv -d -l 1 "$f" output/data_
  
  #populate html file and create .html files
  for file in $(ls output/*.csv)
  do
  
  IFS=","
  while read f1 f2 f3 f4 f5 f6 f7 f8 f9 f10
  do
  
  echo "&lt;table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"&gt; " 
  echo "&lt;tbody&gt;"  
  echo "&lt;tr&gt;  "   
  echo "&lt;td class=\"specsTitle\"&gt;Box&lt;/td&gt; "
  echo "&lt;td class=\"specsDescript stripeBottom\"&gt;$f2&lt;/td&gt; "
  echo "&lt;/tr&gt;     "   
  echo "&lt;tr&gt;  "   
  &lt;snip&gt;
  done &lt;$file  &gt; output/temp.txt
  mv output/temp.txt $file.html
  done
  done
  #remove not important .csv
  rm output/*.csv
  </code></pre>
  
  <p>So at this point I have several .html files in the output folder</p>
  
  <p>The questions are:
  1. How bad is the above code ? :-)
  2. How do I put the code from the .html files in a .csv file that looks like this</p>
  
  <pre><code> col1,col2,col3,HERE SHOULD BE THE HTML CODE FROM FILE1,col5,
   col1,col2,col3,HERE SHOULD BE THE HTML CODE FROM FILE2,col5,  
  </code></pre>
  
  <p>I was thinking of using a template file and somehow add the several .html code. Any help?
  Kind Regards</p>
  
  <p>--EDIT-- 
  THIS IS THE ORIGINAL INPUT
  Original input: </p>
  
  <pre><code> "PC DELL OptiPlex 3010MT i3 3220/2GB/500GB/DVD-RW/FREE DOS / 5Y NBD   
    Intel i3 3220 (Dual Core, 3.30GHz, 3MB, w/ HD2500 Graphics), 2GB (1x2GB) DDR3 PC3-1600MHz, 500GB HDD SATA III 7200rpm, DVD+/-RW (16x), FREE DOS, Warranty: 5Yr Basic Warranty NBD on site"
    "PC DELL OptiPlex 3010MT i5 3470/2GB/500GB/DVD-RW/FREE DOS / 5Y NBD   
     Intel i5 3470 (Quad Core, 3.20GHz Turbo,6MB, w/ HD2500 Graphics), 4GB (1x4GB)      DDR3, PC3-1600MHz, 750GB HDD SATA III 7200rpm, DVD+/-RW (16x), FREE DOS, Warranty: 5Yr   Basic Warranty NBD on site"
  </code></pre>
  
  <p>CSV template</p>
  
  <pre><code>  price,product code, SPECS,other things,
    300.00,CODE 2112334,    ,OTHER STRINGS,
    500.00,CODE 2222222,    ,OTHER STRINGS,
  </code></pre>
  
  <p>Desired .csv output:</p>
  
  <pre><code>  price,product code, SPECS,other things,
    300.00,CODE 2112334, &lt;table style="width:300px"&gt;&lt;tr&gt;&lt;td&gt;Proccessor&lt;/td&gt;&lt;td&gt;Intel i3 3220 (Dual Core, 3.30GHz&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Memmory&lt;/td&gt;&lt;td&gt; 2GB (1x2GB) DDR3 PC3-1600MHz&lt;/td&gt;tr&gt;&lt;td&gt;Hard Disk&lt;/td&gt;&lt;td&gt;500GB HDD SATA III 7200rpm&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;VGA&lt;/td&gt;&lt;td&gt;HD2500 Graphics&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Warranty&lt;/td&gt;&lt;td&gt;5Yr Basic Warranty NBD on site&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Ohter features&lt;/td&gt;&lt;td&gt;THIS IS NOT FROM THE SPECFILE&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Ohter features 2&lt;/td&gt;&lt;td&gt;THIS IS ALSO NOT FROM THE SPECFILE&lt;/td&gt;&lt;/tr&gt;&lt;/tr&gt;&lt;/table&gt;,OTHER STRINGS,
    500.00,CODE 2222222, &lt;table style="width:300px"&gt;&lt;tr&gt;&lt;td&gt;Proccessor&lt;/td&gt;&lt;td&gt;Intel i5 3470 (Quad Core 3.20GHz)&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Memmory&lt;/td&gt;&lt;td&gt; 4GB (1x4GB) DDR3 PC3-1600MHz&lt;/td&gt;tr&gt;&lt;td&gt;Hard Disk&lt;/td&gt;&lt;td&gt;750GB HDD SATA III 7200rpm&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;VGA&lt;/td&gt;&lt;td&gt;HD2500 Graphics&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Warranty&lt;/td&gt;&lt;td&gt;5Yr Basic Warranty NBD on site&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Ohter features&lt;/td&gt;&lt;td&gt;THIS IS NOT FROM THE SPECFILE&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;Ohter features 2&lt;/td&gt;&lt;td&gt;THIS IS ALSO NOT FROM THE SPECFILE&lt;/td&gt;&lt;/tr&gt;&lt;/tr&gt;&lt;/table&gt;,OTHER STRINGS,
  </code></pre>
  
  <p>--EDIT--</p>