CSV Import is a Codeigniter spark which makes it easy to import a CSV file into an associative array.
NOTE: I've not used this code in about 3 years, and will no longer offer any type of support. However, feel free to use this code at your own risk.
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.
For mac formatted csv files, you will need to specify for the library to auto detect line endings. Thanks to Ryan Mueller for this patch.
$this->csvimport->get_array('test.csv', "", TRUE);