ini_set('auto_detect_line_endings', true);
$rows = array();
// Load the csv file.
if ($csv_file = file_load($form_state['values']['csv_file'])) {
if (($handle = fopen($csv_file->uri, "r")) !== FALSE) {
while (($data = fgetcsv($handle, NULL, ",")) !== FALSE) {
array_push($rows, $data);
}
}
}
if ($rows) {
// Remove the header row from the array.
array_shift($rows);
// Process the data the way you want it.
}
Last active
May 10, 2017 04:01
-
-
Save iamstoick/e0b0956f759cfbffb65a6209a3bce202 to your computer and use it in GitHub Desktop.
Parse CSV via FAPI
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment