title: php compare two file sizes then change file name if one is larger
body: <p>I am new here and need a bit of help. I have a php script which is pulling data out of a database and creating .csv files. I need to add some logic to the script which can compare two files and then rename the file if the files size is equal to or greater than a specific (TBD) size. </p>
  
  <p>Basically this script runs twice a hour and I would only like the .csv files rewritten if the file size is large enough. THis is all in hopes that It will prevent .csv files being created which are incomplete or too small. </p>
  
  <p>This a bit of the code which is creating the .csv documents. Any help would be much appreciated. </p>
  
  <pre><code>$course_csv = fopen('/Course.csv','w');
  $courses_u = array_unique($courses, SORT_REGULAR);
  foreach($courses_u as $course){
      fputcsv($course_csv, $course, '|');
  }
  fclose($course_csv);
  
  
  
  $data = file('/Course.csv');
  $handle = fopen("/Course.csv", "w");
  foreach ($data as $line) {
      $line = str_replace(array("\r\n", ',','"'), "", $line);
      fwrite($handle, "{$line}");
  </code></pre>