Here's my 2-cents on the topic...
Take a look at phpmyadmin....you'll be able to see some samples of php code implementing table creation and dba scripts on a db. Your first task would be to interpret the csv file and use the first line as the "header" row. Create a new db table with the columns identified by the header row. Then, do inserts of the data into your new table. You can then run sql queries against the table. Some may say use arrays and memory, but then you may run into problems intepreting and processing your own queries against data stored in memory. By creating a db table with the data, you'll at least be able to leverage the sql language.
Good luck!