title: Tcl to write a file using csv
body: <p>I need help writing a tcl, which reads portions of data from a csv file and write into a text file in the following pattern.</p>
  
  <p><code>NAME : 
  FROM= -100 -346 -249 -125
  TO= -346 -249 -125 100
  COLOR= COLOR1 COLOR2 COLOR3 COLOR4</code></p>
  
  <p>NAME will be a fixed row, </p>
  
  <p>FROM and TO information should be retreived from csv file and </p>
  
  <p>COLOR information can be hardcoded array of colors from the Tcl itself.</p>
  
  <p>From csv data below, the first value(-100) under MIN will be the first value(-100) under FROM of text file. The last value(100) from excel MAX column will be the last value(100) under text file TO column. The values under VALUE column in excel will be rounded and used as TO and FROM per pattern shown.</p>
  
  <pre>
  Data    VALUE   
  100 -345.8756   
  200 -249.3654   
  300 -125.3554   
  COUNT   MIN MAX
  1   -100    -98
  93  84  86
  98  94  96
  99  96  98
  100 98  100
  </pre>
  
  <p><img src="https://i.stack.imgur.com/G26Vd.jpg" alt="enter image description here"></p>