Php ver. 5.4.45 First the code:
$path = DATA_PATH.DS.$token.DS."docsIn".DS;
$fname = $section['subject']."-".$token."--".$i.".csv";
$fhandle = fopen($path.$fname, "r");
if(!$fhandle) {
$report[] = "Failed to create a file handle for: ".$path.$fname;
}
$report[] = "Reading the file: ".$fname;
$waste = fgetcsv($fhandle); // Dump the header row
$waste = fgetcsv($fhandle); // Dump the column labels
$ctr = 0;
while ( (($data = fgetcsv($fhandle, 1000, ",")) !== FALSE) ) {
$key = $data[0];
$val = $data[3];
if( (($val - $section['max']) * ($val - $section['min'])) > 0) {
$report[] = "Failed score: ".$val." not in permitted range (min/max: ".$section['min']."/".$section['max'].") for image ID: ".$key." in file: ".$path.$fname;
} else {
if($i === 0) {
$scores[$key] = array(0,0,0);
}
$scores[$key][$i] = $val;
$ctr++;
} // if( (($val - $section['max']) * ($val - $section['min'])) > 0)
} // while ( (($data = fgetcsv($fhandle, 1000, ",")) !== FALSE) )
$report[] = "Done reading file of ".$ctr." lines";
- The input files are between 150 and 350 lines of csv data. -The files are three sets of two files.
-
Each set of files are identical(generated and sent to the three judges by php) except for the score.
-
Both files from two of the judges are read and processed and both of the files from one of the judges fail and report zero lines.
- Finally in a text editor I copied the data and saved it as a new file and Bingo-problem solved.
- Except this process of copying and saving to a new file is unacceptable.
Only in the File Info from the files context drop down menu can I see a difference.
In a section headed More Info is there any difference. The files which are read have this section empty while the problem files contain information of the person who sent me the file. Name, email and other info. (unable to send an image of this)
Also this information seems to survive the files being ftp'd from my desktop to my host server.
So my question is "Is fgetcsv broken" or how to read a file with this type of file header?
