Skip first row of csv file

the code below loops through the columns in a csv file (ignoring the 1st, 3rd and 57th col). im wondering how i can get it to skip the first ROW of data, which are the column titles?

while($csv_line = fgetcsv($fp)) {
	for($i=0; $i<83; $i++) {					
		if( $i !== 1 && $i !== 3 && $i !== 57) {							
			$val = trim($csv_line[$i]);							
			$extras[] = $csv_line[$i];					
		}
}

What about…


while($csv_line = fgetcsv($fp)) {
    for($i=0; $i<83; $i++) {                    
        if( $i !== 0 && $i !== 1 && $i !== 3 && $i !== 57) {                            
            $val = trim($csv_line[$i]);                            
            $extras[] = $csv_line[$i];                    
        }
}

?

SilverB.

— EDIT —

Maybe a little bit cleaner.


<?php

//--> Define the lines to skip here.
$aSkipLines = array(0,1,3,57);

//--> Process CSV
while($csv_line = fgetcsv($fp)) {
    for($i=0; $i<83; $i++) {                    
        if(!in_array($i,$aSkipLines,true)) {                            
            $val = trim($csv_line[$i]);                            
            $extras[] = $csv_line[$i];                    
        }
}

?>

that skips columns, not rows: 0 is the first column header, 1 is the second column header, etc …

Oops!

What about?


<?php

//--> Define the columns to skip here.
$aSkipLines = array(1,3,57);

//--> Process CSV
while($csv_line = fgetcsv($fp)){
    $c++;
    if($c !== 1)
    {
        for($i=0; $i<83; $i++) {                    
            if(!in_array($i,$aSkipLines,true)) {                            
                $val = trim($csv_line[$i]);                            
                $extras[] = $csv_line[$i];                    
            }
        }
    }
}

?>

Sorry, its early!

Hi wondered if someone could help me i have a csv import script :slight_smile: and am using OpenCart :slight_smile: but should be the same kind of process :slight_smile:

I have this code:

if (isset($data['product_image'])) {
			foreach ($data['product_image'] as $image) {

			$image = $image.".jpg";
			$image = str_replace (" ", "", $image);
			
			$filename = '/home/purchase/public_html/fancydresscostumesonline.co.uk/image/'. $image;

			if (file_exists($filename)) {
			$this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = '" . $this->db->escape($image) . "'");	
			} else {
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_image SET product_id = '" . (int)$product_id . "', image = 'no_image.jpg'");
			}
			
			}

what this code does is it has say numbers 00567 and then this code adds .jpg at the end of it so looks like 00567.jpg and then the else adds a no_image.jpg if there is no data in the product_image fields but what i need to do is change the no_image.jph else part to SKIP the csv file cells for product_image if there is no DATE in there any ideas.

Thanks
Aaron

Hi Aaron, welcome to SitePoint.

I see no mention of DATE in your code, how is this accessed?

Well thats part of the code lol :). not allo of it as thats the part i believe it can be added by :).

I am using a ecommerce shopping cart caleld: OpenCart i have put it on there but no reply so i thought i would try some where else to get help.

I have attached the file which controls the bit i need to be fixed :slight_smile:

and then if you look in there your see things like num_rols = 0 etc

and then you look futher: and find: //Additional Images which is the part i need to skip cells if empty

Regards,
Aaron


<?php
class ControllerToolCsvImport extends Controller {
	private $error = array();
	private $field_names = array();
	private $total_items_added = 0;
	private $total_items_updated = 0;
	private $total_items_skipped = 0;
	private $total_items_missed = 0;

	public function index() {
		$this->load->language('tool/csv_import');

		$this->document->title = $this->language->get('heading_title');


		$this->load->model('setting/setting');
		$this->load->model('localisation/stock_status'); //For getStockStatuses()
		$this->load->model('localisation/language'); //For getLanguages()
		$this->load->model('localisation/length_class'); //For getLengthClasses()
		$this->load->model('localisation/weight_class'); //For getWeightClasses()	
		$this->load->model('localisation/tax_class'); //For getTaxClasses()	
		$this->load->model('tool/csv_import'); //For getManufacturerId() and getCategoryId()
		$this->load->model('setting/store'); //For getStores()
		$this->load->model('catalog/product'); //For addProduct() and getProductCategories()
		$this->load->model('catalog/category'); //For addCategory()
		$this->load->model('catalog/manufacturer'); //For addManufacturer()
		

		// GET CSV AND BULK SETTINGS
		$csv_settings = array(
			'csv_import_delimiter',
			'csv_import_escape',
			'csv_import_qualifier',
			'csv_import_stock_status_id',
			'csv_import_length_class',
			'csv_import_weight_class',
			'csv_import_tax_class',
			'csv_import_subtract',
			'csv_import_language',
			'csv_import_store',
			'csv_import_type',
			'csv_import_update_field',
			'csv_import_feed_url',
			'csv_import_ignore_field',
			'csv_import_ignore_value'
		);
		foreach ($csv_settings as $setting) {
			if (isset($this->request->post[$setting])) {
				$this->data[$setting] = $this->request->post[$setting];
			} else {
				$this->data[$setting] = $this->config->get($setting);
			}
		}
		
		// GET HEADINGS INFO
		$headings_info = array(
			'csv_import_field_name' => 'name',
			'csv_import_field_meta_desc' => 'meta_description',
			'csv_import_field_meta_keyw' => 'meta_keywords',
			'csv_import_field_image' => 'image',
			'csv_import_field_additional_image' => 'product_image',
			'csv_import_field_price' => 'price',
			'csv_import_field_cost' => 'cost',
//			'csv_import_field_special_price' => 'special',
			'csv_import_field_desc' => 'description',
			'csv_import_field_cat' => 'category',
			'csv_import_field_manu' => 'manufacturer',
			'csv_import_field_model' => 'model',
			'csv_import_field_sku' => 'sku',
			'csv_import_field_quantity' => 'quantity',
			'csv_import_field_weight' => 'weight',
			'csv_import_field_length' => 'length',
			'csv_import_field_height' => 'height',
			'csv_import_field_gender' => 'gender',
			'csv_import_field_size' => 'size',
			'csv_import_field_keyword' => 'keyword',
			'csv_import_field_tags' => 'product_tags'
		);
		
		foreach ($headings_info as $key => $value) {
			if (isset($this->request->post[$key])) {
				$this->data[$key] = $this->request->post[$key];
				$this->field_names[$value] = $this->request->post[$key];
			} else {
				$this->data[$key] = $this->config->get($key);
			}
		}
		if (isset($this->request->post['csv_import_field_cat'])) {
			unset($this->request->post['csv_import_field_cat']);
		}
		if (isset($this->request->post['csv_import_field_additional_image'])) {
			unset($this->request->post['csv_import_field_additional_image']);
		}
		
		// GET OTHER INFO
		$this->data['stock_status_selections'] = $this->model_localisation_stock_status->getStockStatuses();
		$this->data['language_selections'] = $this->model_localisation_language->getLanguages();
		$this->data['num_stores'] = $this->model_setting_store->getTotalStores();
		$this->data['store_selections'] = $this->model_setting_store->getStores();
		$this->data['weight_class_selections'] = $this->model_localisation_weight_class->getWeightClasses();
		$this->data['length_class_selections'] = $this->model_localisation_length_class->getLengthClasses();
		$this->data['tax_class_selections'] = $this->model_localisation_tax_class->getTaxClasses();
		
		// DO THE IMPORT
		if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
			
			$this->model_setting_setting->editSetting('csv_import', $this->request->post);	
			
			
			if (is_uploaded_file($this->request->files['csv_import']['tmp_name'])) {
				
				//GET FEED FROM POSTED FILE
				$has_content = file_get_contents($this->request->files['csv_import']['tmp_name']);
				$filename = $this->request->files['csv_import']['tmp_name'];
			} 
			elseif (isset($this->request->post['csv_import_feed_url'])) {
				//GET FEED WITH CURL AND PARSE
				$ch = curl_init();
				$filename = "csv_feed.txt";
				$fp = fopen($filename, "w");
				curl_setopt($ch, CURLOPT_URL, $this->request->post['csv_import_feed_url']);
				curl_setopt($ch, CURLOPT_FILE, $fp);
				curl_exec($ch);
				curl_close($ch);
				fclose($fp);
				$has_content = file_get_contents($filename);
			}
			else {
				$has_content = false;
			}

			if ($has_content) {
				//now we know there is a file, we will delete existing products if necessary
				if ($this->request->post['csv_import_type'] == 'reset') {
					$this->model_tool_csv_import->emptyTables();
				}
				$delim = $this->data['csv_import_delimiter'];
				if ($delim == '\	' ) {
					$delim = "\	";
				}
				elseif ($delim == '') {
					$delim = ",";
				}
				$this->csvImport($filename, $delim);

				$this->session->data['success'] = sprintf($this->language->get('text_success'), $this->total_items_added, $this->total_items_updated, $this->total_items_skipped, $this->total_items_missed);

				$this->redirect(HTTPS_SERVER . 'index.php?route=tool/csv_import&token=' . $this->session->data['token']);
			}
			else {
				$this->error['warning'] = $this->language->get('error_empty');
			}
		}


		// SPECIFY REQUIRED LANGUAGE TEXT
		$language_info = array(
			'heading_title',
			'button_import',
			'button_save',
			'button_cancel',
			'entry_import_file',
			'entry_import_url',
			'entry_ignore_fields',
			'entry_store',
			'entry_language',
			'entry_stock_status',
			'entry_weight_class',
			'entry_length_class',
			'entry_tax_class',
			'entry_field_mapping',
			'entry_subtract',
			'entry_format',
			'entry_delimiter',
			'entry_data_feed',
			'entry_escape',
			'entry_qualifier',
			'entry_import_type',
			'text_add',
			'text_reset',
			'text_update',
			'text_update_explain',
			'text_field_oc_title',
			'text_field_csv_title',
			'text_field_name',
			'text_field_price',
			'text_field_cost',
//			'text_field_special_price',
			'text_field_model',
			'text_field_sku',
			'text_field_manufacturer',
			'text_field_category',
			'text_field_quantity',
			'text_field_image',
			'text_field_additional_image',
			'text_field_description',
			'text_field_meta_desc',
			'text_field_meta_keyw',
			'text_field_weight',
			'text_field_length',
			'text_field_height',
			'text_field_gender',
			'text_field_size',
			'text_field_keyword',
			'text_field_tags'
		);
		
		// GET REQUIRED LANGUAGE TEXT
		foreach ($language_info as $language) {
			$this->data[$language] = $this->language->get($language); 
		}
		
		// Warning or success message
 		if (isset($this->error['warning'])) {
			$this->data['error_warning'] = $this->error['warning'];
		} else {
			$this->data['error_warning'] = '';
		}

		if (isset($this->session->data['success'])) {
			$this->data['success'] = $this->session->data['success'];
			unset($this->session->data['success']);
		} else {
			$this->data['success'] = '';
		}

		// BCT
  		$this->document->breadcrumbs = array();

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER . 'index.php?route=common/home&token=' . $this->session->data['token'],
       		'text'      => $this->language->get('text_home'),
      		'separator' => FALSE
   		);

   		$this->document->breadcrumbs[] = array(
       		'href'      => HTTPS_SERVER . 'index.php?route=tool/csv_import&token=' . $this->session->data['token'],
       		'text'      => $this->language->get('heading_title'),
      		'separator' => ' :: '
   		);
		
		// Control buttons in admin
		$this->data['cancel'] = HTTPS_SERVER . 'index.php?route=extension/feed&token=' . $this->session->data['token'];

		$this->data['restore'] = HTTPS_SERVER . 'index.php?route=tool/csv_import&token=' . $this->session->data['token'];

		$this->data['csv'] = HTTPS_SERVER . 'index.php?route=tool/csv_import&token=' . $this->session->data['token'];

		$this->data['csv_import'] = HTTPS_SERVER . 'index.php?route=tool/csv_import&token=' . $this->session->data['token'];

		// Render resposne with header and footer
		$this->template = 'tool/csv_import.tpl';
		$this->children = array(
			'common/header',
			'common/footer'
		);
		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
	}

	private function validate() {
		if (!$this->user->hasPermission('modify', 'tool/csv_import')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}

		if (!$this->error) {
			return TRUE;
		} else {
			return FALSE;
		}
	}
	
	public function csvImport($file, $delim=",", $qual='"', $escape='"') {

		ini_set('max_execution_time', 999999); // prevent timeout

		//required desc data
		$desc_data = array(
			'name' => 'No Title',
			'description' => '',
			'meta_keywords' => '',
			'meta_description' => '',
		);
		
		//required product data
		$prod_data = array(
			'date_available' => date('Y-m-d', time()-86400),
			'model' => '',
			'sku'	=> '',
			'location' => '',
			'manufacturer_id' => 0,
			'shipping' => 1,
			'image' => '',
			'quantity' => 1,
			'minimum' => 1,
			'subtract' => $this->data['csv_import_subtract'],
			'sort_order' => 1,
			'price' => 0.00,
			'cost' => 0.00,
			'status' => 1,
			'tax_class_id' => $this->data['csv_import_tax_class'],
			'weight' => '',
			'weight_class_id' => $this->data['csv_import_weight_class'],
			'length' => '',
			'width' => '',
			'height' => '',
			'gender' => '',
			'size' => '',
			'length_class_id' => $this->data['csv_import_length_class'],
			'product_category' => array(0),
			'keyword' => '',
			'stock_status_id' => $this->data['csv_import_stock_status_id']
		);
		
		//FUTURE required special price data
//		$special_data = array(
//			'customer_group_id' => 8,
//			'priority' => 1,
//			'price' => 0,
//			'date_start' => date('Y-m-d', time()-86400),
//			'date_end' => '0000-00-00',
//		);
		
		/** Just for reference....
		$manu_data = array(
			'manufacturer_name' => '',
			'keyword' => '',
			'sort_order' => 0,
			'manufacturer_store' => array()
		);
		
		$cat_data = array(
			'parent_id' => 0,
			'sort_order' => 0,
			'status' => 1,
			'category_description'=> array(),
			'category_store'=> array(),
			'keyword' => ''
		);
		**/

	    $fh = fopen($file, 'r');
	    if(!$fh) die('File no good!');

		// Get headings
		$headings = fgetcsv($fh, 0, $delim);
		$num_cols = sizeof($headings);
	    $num_rows = 0;

	    //Read the file as csv
	    while (($row = fgetcsv($fh, 0, $delim)) !== FALSE) {
			//skip product if broken row (although broken row probably means broken whole file)
			if (sizeof($row) != $num_cols) {
				$this->total_items_missed++;
	    		continue;
	    	}
			
			$raw_prod = array(); // will contain product from csv
	    	$new_manu = array(); // will contain new manufacturer to add
	    	$product = array();  // will contain new product to add
			$new_cat = array(); // will contain new category to add
			
	        for ($i=0; $i<sizeof($headings); $i++) {
	        	$raw_prod[$headings[$i]] = $row[$i];
	        }
			
			//skip if ignore_field == ignore_value
			if (isset($this->data['csv_import_ignore_field']) && isset($this->data['csv_import_ignore_value'])) {
				if (isset($raw_prod[$this->data['csv_import_ignore_field']])) {
					if ($raw_prod[$this->data['csv_import_ignore_field']] == $this->data['csv_import_ignore_value']) {
						$this->total_items_skipped++;
						continue;
					}
				}
			}
			
	    	//price - remove leading $ or pound or euro symbol, remove any commas.
			foreach (array('price', 'cost') as $price) {
				if (isset($this->field_names[$price]) && isset($raw_prod[$this->field_names[$price]])) {
					$first = substr($raw_prod[$this->field_names[$price]], 0, 1);
					if (!is_numeric($first)) {
						$raw_prod[$this->field_names[$price]] = substr($raw_prod[$this->field_names[$price]], 1);
					}
					$raw_prod[$this->field_names[$price]] = preg_replace('/,/is', '', $raw_prod[$this->field_names[$price]]);
				}
			}
			
			// Is this an update?
			$update_id = 0;
			$existing_product = array();
			if ($this->data['csv_import_type'] == 'update') {
				$update_value = $raw_prod[$this->field_names[$this->data['csv_import_update_field']]];
				$update_id = $this->model_tool_csv_import->getProductID($this->data['csv_import_update_field'], $update_value);
			}
    		
			if ($update_id) {
				//update the product in place
				$product = $this->model_catalog_product->getProduct($update_id);
				$product['product_description'] = $this->model_catalog_product->getProductDescriptions($update_id);
				$product['product_category'] = $this->model_catalog_product->getProductCategories($update_id);
				$product['product_options'] = $this->model_catalog_product->getProductOptions($update_id);
//				$product['product_specials'] = $this->model_catalog_product->getProductSpecials($update_id);
				$product['product_download'] = $this->model_catalog_product->getProductDownloads($update_id);
				$product['product_related'] = $this->model_catalog_product->getProductRelated($update_id);
//				$product['product_discounts'] = $this->model_catalog_product->getProductDiscounts($update_id);
				$product['product_store'] = $this->model_catalog_product->getProductStores($update_id);
				$product['product_tags'] = $this->model_catalog_product->getProductTags($update_id);

				$product_images = $this->model_catalog_product->getProductImages($update_id);
				foreach ($product_images as $product_image) {
					$product['product_image'][] = $product_image['image'];
				}
				foreach ($prod_data as $field => $default_value) {
					if (isset($this->field_names[$field]) && isset($raw_prod[$this->field_names[$field]])) {
						$product[$field] = $raw_prod[$this->field_names[$field]];
					}
				}
				// loop over desc_data array adding description table data
				foreach ($desc_data as $field => $default_value) {
					if (isset($this->field_names[$field]) && isset($raw_prod[$this->field_names[$field]])) {
						$product['product_description'][$this->data['csv_import_language']][$field] = $raw_prod[$this->field_names[$field]];
					}
				}
				
				//SEO Keyword
				if (isset($this->field_names['keyword']) && isset($raw_prod[$this->field_names['keyword']])) {
					$product['keyword'] = $raw_prod[$this->field_names['keyword']];
				}
				//Product Tags
				if (isset($this->field_names['product_tags']) && isset($raw_prod[$this->field_names['product_tags']])) {
					$product['product_tags'][$this->data['csv_import_language']] = $raw_prod[$this->field_names['product_tags']];
				}
				//Additional Images
				for ($i=0; $i<sizeof($this->field_names['product_image']); $i++) {
					if (isset($raw_prod[$this->field_names['product_image'][$i]])) {
						$product['product_image'][] = $raw_prod[$this->field_names['product_image'][$i]];
					}
				}
				
				//UPDATE THE PRODUCT
				$this->model_catalog_product->editProduct($update_id, $product);
				$this->total_items_updated++;
			}
			else {
				//add the product to a category
				$parentid = 0;
				for ($i=0; $i < sizeof($this->field_names['category']); $i++) {
					if (isset($raw_prod[$this->field_names['category'][$i]]) && $raw_prod[$this->field_names['category'][$i]] != '') {
						$cat_id = (int)$this->model_tool_csv_import->getCategoryId($raw_prod[$this->field_names['category'][$i]], $parentid);
						if ($cat_id == 0) {
							//doesn't exist so add it then get it's id
							$new_cat = array();
							$new_cat['parent_id'] = $parentid;
							$new_cat['sort_order'] = 0;
							$new_cat['status'] = 1;
							$new_cat['keyword'] = '';
							$new_cat['category_description'][$this->data['csv_import_language']]['name'] = $raw_prod[$this->field_names['category'][$i]];
							$new_cat['category_description'][$this->data['csv_import_language']]['description'] = '';
							$new_cat['category_description'][$this->data['csv_import_language']]['meta_description'] = '';
							$new_cat['category_description'][$this->data['csv_import_language']]['meta_keywords'] = '';
							$new_cat['category_store'] = array(0);
							$this->model_catalog_category->addCategory($new_cat);
							$cat_id = (int)$this->model_tool_csv_import->getCategoryId($raw_prod[$this->field_names['category'][$i]], $parentid);
						}
						$this->field_names['product_category'] = 'product_category';
						if ($i == sizeof($this->field_names['category']) - 1 || $raw_prod[$this->field_names['category'][$i+1]] == '') {
							$raw_prod['product_category'] = array($cat_id);
						}
						$parentid = $cat_id;
					}
				}
				
				//set the manufacturer_id, adding the manufacturer if necessary.
				if (isset($raw_prod[$this->field_names['manufacturer']])) {
					$manu_id = $this->model_tool_csv_import->getManufacturerId($raw_prod[$this->field_names['manufacturer']]);
					if ($manu_id == 0) {
						//doesn't exist so add it then get it's id
						$new_manu['name'] = $raw_prod[$this->field_names['manufacturer']];
						$new_manu['keyword'] = '';
						$new_manu['sort_order'] = 1;
						$new_manu['manufacturer_store'] = array(0);
						$this->model_catalog_manufacturer->addManufacturer($new_manu);
						$manu_id = $this->model_tool_csv_import->getManufacturerId($new_manu['name']);
					}
					$this->field_names['manufacturer_id'] = 'manufacturer_id';
					$raw_prod['manufacturer_id'] = $manu_id;
				}
				
				// loop over prod_data array adding product table data
				foreach ($prod_data as $field => $default_value) {
					if (isset($this->field_names[$field]) && isset($raw_prod[$this->field_names[$field]])) {
						
						$product[$field] = $raw_prod[$this->field_names[$field]];
					}
					else {
						$product[$field] = $default_value;
					}
				}
				
				//Optional Import Fields:
				
				//SEO Keyword
				if (isset($this->field_names['keyword']) && isset($raw_prod[$this->field_names['keyword']])) {
					$product['keyword'] = $raw_prod[$this->field_names['keyword']];
				}
				//Product Tags
				if (isset($this->field_names['product_tags']) && isset($raw_prod[$this->field_names['product_tags']])) {
					$product['product_tags'][$this->data['csv_import_language']] = $raw_prod[$this->field_names['product_tags']];
				}
				else {
					$product['product_tags'] = array();
				}
				//Additional Images
				$product['product_image'] = array();
				for ($i=0; $i<sizeof($this->field_names['product_image']); $i++) {
					if (isset($raw_prod[$this->field_names['product_image'][$i]])) {
						$product['product_image'][] = $raw_prod[$this->field_names['product_image'][$i]];
					}
				}
				
				// loop over desc_data array adding description table data
				foreach ($desc_data as $field => $default_value) {
					if (isset($this->field_names[$field]) && isset($raw_prod[$this->field_names[$field]])) {
						$product['product_description'][$this->data['csv_import_language']][$field] = $raw_prod[$this->field_names[$field]];
					}
					else {
						$product['product_description'][$this->data['csv_import_language']][$field] = $default_value;
					}
				}
				// adding product to store
				if (isset($this->data['csv_import_store'])) {
					$product['product_store'][] = $this->data['csv_import_store'];
				}else {
					$product['product_store'] = array(0);
				}
				
				
				// adding product special price
//				if (isset($this->field_names['special']) && isset($raw_prod[$this->field_names['special']])) {
//					foreach ($special_data as $field => $default_value) {
//						if (isset($this->field_names[$field]) && isset($raw_prod[$this->field_names[$field]])) {
//							$product['product_special'][$field] = $raw_prod[$this->field_names[$field]];
//						}
//						else {
//							$product['product_special'][$field] = $default_value;
//						}
//					}
//				}
				
				
				//ADD THE PRODUCT
				$this->model_catalog_product->addProduct($product);
				$this->total_items_added++;
			
			}
			
	        $num_rows++;
	    }

	    fclose($fh);

	    return $num_rows;
	}
	
}
?>

Do i just replace with the code you placed there? as its same in my file i know but you never put what is needed to be done lol

I’m still unsure as what you need, but here’s a simplified example on how to skip rows. Where the code says ‘continue’, you can think of as implying ‘skip’. :slight_smile:

You should be able to apply the same logic to your problem.


<?php
foreach($file as $row){
  
  if(empty($row['date'])){
    continue;
  }
  
  $image = 'default.jpg';
  
  if( ! empty($row['product_image'])){
    $image = trim($row['product_image']) . '.jpg';
  }
  
  $image = '/home/purchase/public_html/fancydresscostumesonline.co.uk/image/' . $image ;
  
  if( ! file_exists($image)){
    continue;
  }
  
  $this->db->query(sprintf(
    "INSERT INTO %s SET product_id = %d, image = '%s';",
    DB_PREFIX . 'product_image',
    $product_id,
    $this->db->escape($image)
  ));
  
}

Here’s the manual pages for continue and [fphp]sprintf[/fphp], just in case.

Ok well waht i need the product_image is imported into ths database with numbers like 001 andf then the .jpg adds the 001.jpg at the end once imported but what i need is for example there is only 2 additional images for product 1 so then i need it to skip the ones which are empty for that product etc so for example

these are the fields in the csv:

acc_code1
acc_code2
acc_code3
acc_code4
acc_code5
alt_code1
alt_code2 - 001
alt_code3 - 002
alt_code4
alt_code5

as you see for product one it only has alt_code2 and alt_code3 well what i need it to do now is SKIP acc_code1, acc_code2, acc_code3, acc_code4, acc_code5, alt_code1, alt_code4 and alt_code5 for this product and do the same for the rest but it might not be in this sequence for all the products.

As the way the csv import works is i login to opencart backend and then go to the csv import and for the additional image text box i do

acc_code1 and then hit the plus + which means add and then do acc_code2 etc.

Regards,
Aaron

Regards,
Aaron