Extract some of the fields from plain .sql file and write all rows to .csv using php



I have an .sql file which contains some data like "first_name", "last_name", "email" etc.

What I want to achieve is extraction of some of the fields (let's say "first_name" and "last_name" only) and save them into .csv file.