i have an affliate window CSV which has nearly 1 lac rows, i want to save this as nodes, and i tried with batch API.
but still i am getting php timeout error ..please help
function MODULE_aw_batch(){
$operations = array();
$csv = file_directory_path().'/aw/datafeed_134642.csv';
$file = fopen($csv, 'r');
while (($data = fgetcsv($file)) !== FALSE) {
$operations[] = array('MODULE_aw_op', array($data));
}
$batch = array(
'title' => t('Generating feeds'), // Title to display while running.
'operations' => $operations,
'finished' => 'MODULE_aw_finished', // Last function to call.
'init_message' => t('Importing...it may take 4-5 hours'),
'progress_message' => t('Processed @current out of @total.'),
'error_message' => t('Import feeds has encountered an error.'),
);
batch_set($batch);
batch_process('admin/content/node/overview');
}
update (solved)
instead of reading whole csv file at a time, split the csv to read 5 lines per process
Found the solution
Batch declaration