Import CSV file with table creation


I am struggling to import data from Department(CSV Candidate file).

The problem is I have to import these CSV files:

First Row = ClientName: Facebook
Second Row = Name | Age | Location -> Header
Third Row = Mark | 33 | America -> Data records
Fourth Row = Sheryl | 38 | America -> Data records

A table with the CSV filename has to be created and then the records inserted.

Everytime an upload happens, a script has to run to check for the table’s existence. If it exists, the records are inserted. If it does not exist, the table is created and then the records are inserted.

The filename is NOT inserted into the table.

Each client has a different table created for their records.

Once more, the tables are created the first time the CSV is uploaded.

How can we implement this in Drupal 7 ??

Your help will be greatly appreciated…

Drupal version: