I want to validate:
1) That the CSV file has the number of fields that are required (in my case 6).
2) That the CSV file has at least one record to work with.
I do not need to validate that the file exists.
The following code shows the number of fields per record that the CSV file has.
<?php
$fila = 1;
$gestor = fopen("C:\archivo.csv", "r")
while (($datos = fgetcsv($gestor, 1000, ",")) !== FALSE) {
$numero = count($datos);
echo "$numero de campos en la línea $fila </br>";
$fila++;
}
fclose($gestor);
?>
I want to simplify the code to achieve what I indicated. The file contains a header.