public function SourceCsvForm::getFileColumnCount in Migrate Tools 8.4
Returns the count of fields in the header row.
Use a new file handle so that CSVFileObject::current() is not executed.
Return value
int The number of fields in the header row.
1 call to SourceCsvForm::getFileColumnCount()
- SourceCsvForm::buildForm in src/
Form/ SourceCsvForm.php - Form constructor.
File
- src/
Form/ SourceCsvForm.php, line 413
Class
- SourceCsvForm
- Provides an edit form for CSV source plugin column_names configuration.
Namespace
Drupal\migrate_tools\FormCode
public function getFileColumnCount() {
$count = 0;
$fname = $this->file
->getPathname();
$handle = fopen($fname, 'r');
if ($handle) {
$row = fgetcsv($handle);
$count = count($row);
fclose($handle);
}
return $count;
}