title: Add data to csv file in specific columns using PHP
body: <p>I have a csv file which has 14 columns, and hundreds of rows. There is a header which is <code>"sku","category","description","brand"</code> etc.</p>
  
  <p>All data is allready there but I'm trying to add some image filenames inside the CSV, in some specific columns <code>( "images", "small_image" , "thumnail" ).</code></p>
  
  <p>The header kind of looks like this:</p>
  
  <pre><code>+-----+----------+-------------+-------+-------------+-----------+--------+------+
  | sku | category | description | image | small_image | thumbnail |  price | color|
  +-----+----------+-------------+-------+-------------+-----------+--------+------+
  </code></pre>
  
  <p>so knowing how the header looks like, then the first row would be like: </p>
  
  <pre><code>+-------+---------------+------------------+---+---+----+-----+--------+
  | sku01 | category name | description here |   |   |    | 99$ | black  |
  +-------+---------------+------------------+---+---+----+-----+--------+
  </code></pre>
  
  <p>The filename for the jpeg is the same as the <code>sku</code> value on the same row , with the jpeg extension. So for example, if there is <code>sku01</code> for the <code>sku</code> column on the first row, the filename would be <code>sku01.jpeg</code> in the image column on that same row. So would be the small_image value, and the thumbnail value.</p>
  
  <p><strong>However the filename would only be specified IF the jpeg exist in a folder.</strong></p>
  
  <p>So far I know how to use the fopen function to open the csv file, eventually store all data in an array ( I don't know if that would help in my case ) , then at some point use the fputcsv function after checking if file_exist in the specific folder on the server. </p>
  
  <p>But, to me it's still a big mess in my head as far as in what order I should use the functions. I 'm stuck. Also, I have no idea how to put the jpeg filename in the right columns ( image, thumbnail, small_image), because these columns are in the "middle" of the csv file, among other columns. They are not at the end of the csv file</p>
  
  <p>I would be really thankful to anyone who can put me on the right path.</p>