/csv-import

Import a CSV file into an associative array

Primary LanguagePHP

CSV Import

CSV Import is a Codeigniter spark which makes it easy to import a CSV file into an associative array.

Usage

First you must load the csvimport spark:

$this->load->spark('csvimport/0.0.1')

To import a file, simply run the following command:

$this->csvimport->get_array('test.csv');

It is important to note that this library treats the first row of a CSV file as a column header row.

If you would like to use a different set of column headers, other than what is generated by the file, you submit them as an array.

$this->csvimport->get_array('test.csv', array('id', 'name', 'company', 'phone'));

Warning The function assumes that the number of column headers will match the number of values in each row.