How to validate the headers of a csv uploaded with cck filefield?
Just got this too work:

/**
 * The validation for the stocklist.
 *
 */

function stocklist_validation($field) {
  // variable for error messages
  $errors = array();

  // do some processing on the field / file
  $filepath = $field-&gt;filepath;

 // Open the file

      if ( $handle = fopen($filepath, 'r') ) {
        $line_count = 1 ;
        $first = TRUE ;
        if ( $line = fgetcsv($handle, 4096) ) {

        // Validate the headers 
         if ( $line[0] !== 'something' ) {
            $errors[] = t('Please ensure the files 1st column has the something in it. Including something as the heading.'); 
         }

    if ( $line[1] !== 'somethingelse' ) {
            $errors[] = t('Please ensure the files 2nd column has the somethingelse in it. Including somethingelse as the heading.'); 
         }


        fclose($handle);
      }

           else {
        $errors[] = t('Unable to open uploaded file !filepath.', array('!filepath' =&gt; $filepath));   
       }
      } 
// in case of errors, return error messages

          return $errors;
}


The first function didn't need changing... 

In the second function, it was the fopen() that needed changing. Secondly, like an idiot I just realised that the "valid" file was actually tab delimited... Doh! Would be nice to be able to accept those files too. As some software saves csv files in that format, such as the one I clearly used, OpenOffice.