Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6740741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:38:32+00:00 2026-05-26T11:38:32+00:00

Im using a CSV Import plugin for open cart and by default is completely

  • 0

Im using a CSV Import plugin for open cart and by default is completely skips products if they are missing any of the column fields.
Is there anyway i can read the file and replace all the empty fields with ‘null’ or 0 and send it back to the code.

skipping that check below causes an offset in the reading/placing format !

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

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

    //Read the file as csv
    while (($row = fgetcsv($fh, 0, $delim)) !== FALSE) {

         //missed product if num columns in this row not the same as num headings
     if (count($row) != $num_cols) {
        $this->total_items_missed++;
        continue;
        }   


        for ($i=0; $i<count($headings); $i++) {
            $raw_prod[$headings[$i]] = $row[$i];
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T11:38:33+00:00Added an answer on May 26, 2026 at 11:38 am

    Replace these two lines

    $this->total_items_missed++;
    continue;
    

    with

    $row = array_pad($row, $num_cols, 0);
    

    Which will add any missing values with 0’s

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using the following in Python2.x ; import csv f = open('test.csv', 'wb') writer
How do I import a CSV file using OpenOffice.org APIs? I want to do
I need to import a large CSV file into an SQL server. I'm using
I'm using the jQuery Table to CSV Plugin. I've altered the popup so that
I am trying to import users into AD using a CSV file, PowerShell, and
How do I import CSV files using zend framework? Should I use zend_file_transfer or
I am using python's CSV module to iterate over the rows of a column.
My field is defined as follows COLUMNNAME character(9) I import CSV files using the
I'm trying to export/import data in .csv format using SQLDeveloper. The source and destination
I am using C# to import a CSV with 6-8million rows. My table looks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.