It's in the Import module on the admin side:
https://github.com/DavidJClark/phpvms_5.5.x/blob/master/admin/modules/Import/Import.php#L287
You could do the same and clean it up a little and probably get away with using PilotData::getAllPilots() and looping that through, or querying PilotData::findPilots() with your params/columns.