RO CSVI
Incorrect column count
| RO CSVI
The single most seen message by users is probably the "Incorrect column count".
What does it actually mean?
The incorrect column count means that the columns CSV Improved has found in your file is not the same as the columns in your configuration. Let's clarify this with some examples.
Example 1, incorrect delimiters:
The CSV file looks like this:
"product_sku","poduct_name","category_path"
The template has delimiters set to:
Field delimiter: ^
Text delimiter: ~
Having incorrect delimiters makes it impossible for CSV Improved to read your file. As CSV Improved looks for the ^ character but it cannot find one, it will read the complete line as a single field. This cannot be identified as a supported field and as a result it gives the error message. Always make sure the delimiters match.
Example 2, the trailing field delimiter:
The CSV file looks like this:
product_sku,poduct_name,category_path
PROD1,Product 1,Products/Software,
The field delimiter used is a comma, this means we have a total of 3 fields:
- product_sku
- product_name
- category_path
The product information we want to import has a total of 4 fields:
- PROD1
- Product 1
- Products/Software
Now we can clearly see that there is an incorrect column count because 3 is not the same as 4. Why are there 4 fields for the product information? As we use the comma as field delimiter, after every comma a new field starts. So the comma after Products/Software also creates a new field. The trailing comma must be removed. Always check your file for trailing field delimiters.
Example 3, the duplicate fields:
The CSV file looks like this:
product_sku,poduct_name,product_name,category_path
PROD1,Product 1,Product 1,Products/Software
The field delimiter used is a comma, this means we have a total of 3 fields:
- product_sku
- product_name
- category_path
The product information we want to import has a total of 4 fields:
- PROD1
- Product 1
- Product 1
- Products/Software
Since the product_name field already exists already the same name again is ignored. This leaves you with 3 fields to import while the data contains 4. Either rename or remove the column to solve the issue.
Example 4, the missing field:
The CSV file looks like this:
product_sku,product_name,category_path,product_publish
PROD1,Product 1,Products/Software
The field delimiter used is a comma, this means we have a total of 4 fields:
- product_sku
- product_name
- category_path
- product_publish
The product information we want to import has a total of 3 fields:
- PROD1
- Product 1
- Products/Software
Here we have a situation where the configuration fields are more than the data fields. What happens is that in a spreadsheet program like Excel a cell is not exported until it is "touched". In this case the column header product_publish was added but no value was put in for the product. To solve this the cell must be given a space or anything actually so it becomes a used cell after that it will be exported.
Example 5, the wrong number of fields:
It is possible to use the column headers in a file to tell CSV Improved what fields you want to use. There is another way and that is to assign fields to the template used for import via the templates menu.
The CSV file looks like this:
PROD1,Product 1,Products/Software
The template fields assignment looks like:
product_sku
product_name
attribute
category_path
This means we have a total of 4 fields:
- product_sku
- product_name
- attribute
- category_path
The product information we want to import has a total of 3 fields:
- PROD1
- Product 1
- Products/Software
This is another situation where the configuration fields are more than the data fields. The solution here is to remove the assigned fields that are not being used.
Adding your own custom available fields
| RO CSVI
Requirements: CSVI 5.6+
In CSVI Pro it is possible to add your own custom available fields without having to modify any core files.
Adding fields
Steps to add your own available fields:
- Go to the folder administrator/templates/<template name>/html/com_csvi/<component name>/install/
For example: administrator/templates/isis/html/com_csvi/com_virtuemart/install/ - Create a file called override.sql
- Add the following code in the file:
INSERT IGNORE INTO `#__csvi_availablefields` (`csvi_name`, `component_name`, `component_table`, `component`, `action`) VALUES
('skip', 'skip', 'product', 'com_virtuemart', 'import');
Explanation of the fields:- csvi_name
This is the name of the field used by CSVI (this is usually the same as the component_name) - component_name
The name of the field used in the component table - component_table
The name of the import/export routine where the field is to be used with - component
The name of the component the field is used for
- csvi_name
- Add more lines if needed
- Run the Update from the Available Fields to add your custom available fields
A file with multiple lines could look like this:
INSERT IGNORE INTO `#__csvi_availablefields` (`csvi_name`, `component_name`, `component_table`, `component`, `action`) VALUES
('skip', 'skip', 'product', 'com_virtuemart', 'import'),
('combine', 'combine', 'product', 'com_virtuemart', 'import');
Processing fields
To have CSVI process these custom available fields, you will need to write your own code.
How to collect debug information?
| RO CSVI
Why?
Debug information is very valuable information. The information gives an in-depth look into what is happening inside the program. Troubleshooting problems is made a lot easier as the programmer can see step by step what the program is doing.
How to enable debug info?
CSVI 6
- Go to Templates -> Templates
- Click on the name of your template to Edit the template
- Select the Details tab
- Set the Enable logging to Yes.
- After you ran an import or export, you will be shown the results page and here you can find the debug log options:
These options are also available if you click on Logs in the menu. - There are 3 options available:
- Show
This will show the debug log in a popup window - Open
This will open the debug log in a new window - Download
This will download the debug log in a zip file or if the debug log is too large, it will download as a text file
- Show
- Now you have a debug log.
CSVI 4/5
- Click on Process
- Select Import or Export
- Select your component
- Select the operation you want to perform
- Click on Go
- Under File set the Collect debug information option to Yes. So it looks like this:
- After the Import or Export, click on Show Panel
- Click on Log
- Click on the Import /Export you just did
- See here the Download debug log link:
- Click on the Download link and post the zip file in the forum for checking.
- Now you have a debug log.
Import crashes and no debug log
It can happen that the import crashes and no log details are stored, the debug log is still created but need to be retrieved from the server. The debug logs are stored in the folder logs/ for CSVI 6 and tmp/com_csvi/debug for CSVI 5. Find the last created file in this folder and that will be your debug log for your last import.
Debug information collects a lot of info, it is advised not to use it with large imports, rather use a small sample of a few records.
What to do with the debug output?
Once the debug output is generated it is ready for analysis and can be posted on the forum along with the description of the problem and a sample of the import file. Make sure the debug log is zipped otherwise it cannot be uploaded.
Limiting number of lines in Debug log
Starting from CSVI 7.7.0 version a new feature for limiting the lines in to the debug log has been added. This feature is very helpful in case of Imports with large number of records. Instead of generating a huge debug log with entries of all records and struggling to handling the large debug log file, you can now limit the number of lines in debug log so the generated debug log is small and easy to handle in forum as well as for checking on issues.
To add the number of lines to log file, go to CSVI Dashboard page, click on Options button on top right corner, on Site tab set Number of lines in log file field. By default it is 20.
Checking your PHP version in Joomla
| RO CSVI
PHP 7 is nowadays the default PHP version used by hosting providers. Unfortunately, many hosting providers use older PHP 7 versions. The recommended version is PHP 7.3 or higher but often older PHP versions are still being used. You can check the versions supported by the PHP project. RO CSVI requires a minimum of PHP 7.1. Checking your PHP version in Joomla is very easy.
Fill multiple fields with one value
| RO CSVI
Requirements
- CSVI 5.0+
- VirtueMart 2.0.2
- Joomla 2.5+
- PHP 5.2+
- An existing product import template
- Basic understanding of adding fields to templates
Objective
The objective is to import 1 field from the import file into multiple destination fields. In this example we will import the product name into the fields product name and product short description.
Example data
"product_sku";"product_name"
"AB123";"Product 1"
"CD456";"Product 2"
Setting up the fields
Follow these steps to setup the fields as above:
- Select the product_sku field and click on Add
- Select the product_name field and click on Add
- Select the product_s_desc field and click on Add
Now we have all the three fields as shown in this image:
Configuring the additional destination fields
Now we need to set up the product short description to take the value from the product name as shown below:
- On the Fields tab click on the product_s_desc field to open the edit screen as shown in the image above
- At File field name fill in the field name as set in the field you want to take the value from. In this example we take it from the product_name field. If this field is empty, add the same name as chosen at Template field name. As this field is empty in the product_name field, we add the full name product_name.
- At the Template field name select from which field the product short description should take its value. We want to take the value from the product_name field, so select the product_name field.
- Click on Submit
To make sure that the import uses these settings we just created the option Use column headers as configuration must be set to No. See the settings here:
The settings are done and the file options are set now and the template is ready for import.