Difference between revisions of "X-Cart:Import-Export Troubleshooting"

From X-Cart 4 Classic
Jump to: navigation, search
(Problem 4)
m (CSV import times out before completion. Large numbers of duplicate images are populating the /images/D folder. 'Drop' detailed images does nothing.)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Problem 1 ==
+
== "I cannot import a CSV file I have just exported" ==
  
 
You cannot import a CSV file that you have just exported from your own store. The error message reads:
 
You cannot import a CSV file that you have just exported from your own store. The error message reads:
Line 15: Line 15:
 
You are probably trying to re-import a file that was exported with the option '<u>Do you wish to export images?</u>' enabled. On export, your image files were saved to a temporary directory <u>/var/tmp/export_YYYYMMDD_HHMMSS</u> corresponding to the name of the main export file, while the image filenames were written to the export CSV file without filepaths. As you were not going to import images, you probably failed to specify a '<u>Directory where images are located</u>', which caused the error. To import the CSV file into the store without importing images, remove the column containing image filenames from the CSV file altogether (or create a new export CSV file, this time setting the option '<u>Do you wish to export images?</u>' to 'No').
 
You are probably trying to re-import a file that was exported with the option '<u>Do you wish to export images?</u>' enabled. On export, your image files were saved to a temporary directory <u>/var/tmp/export_YYYYMMDD_HHMMSS</u> corresponding to the name of the main export file, while the image filenames were written to the export CSV file without filepaths. As you were not going to import images, you probably failed to specify a '<u>Directory where images are located</u>', which caused the error. To import the CSV file into the store without importing images, remove the column containing image filenames from the CSV file altogether (or create a new export CSV file, this time setting the option '<u>Do you wish to export images?</u>' to 'No').
  
== Problem 2 ==
+
== "I cannot import a CSV file I have edited in an external editor. The error says "A heading is missing"" ==
  
 
You edited your CSV file in an external spreadsheet editor, and now you cannot import it. X-Cart generates an error like this:
 
You edited your CSV file in an external spreadsheet editor, and now you cannot import it. X-Cart generates an error like this:
Line 29: Line 29:
 
Normally, X-Cart interprets two delimiter symbols following one after another as an empty field; however, the combination must not be used in heading rows like in the example above, as column headings may not be empty. To solve the problem, remove any delimiters leading X-Cart to believe there is an empty column heading.
 
Normally, X-Cart interprets two delimiter symbols following one after another as an empty field; however, the combination must not be used in heading rows like in the example above, as column headings may not be empty. To solve the problem, remove any delimiters leading X-Cart to believe there is an empty column heading.
  
== Problem 3 ==
+
== "I cannot import a CSV file I have edited in an external editor. The error says "Wrong data type"" ==
  
 
You edited your CSV file in an external spreadsheet editor, and now you cannot import it. X-Cart generates an error like this:
 
You edited your CSV file in an external spreadsheet editor, and now you cannot import it. X-Cart generates an error like this:
Line 40: Line 40:
  
  
== Problem 4 ==
+
== "I get errors during CSV import" ==
  
 
Attempting to import a CSV file, you get one or more errors of the following type:
 
Attempting to import a CSV file, you get one or more errors of the following type:
Line 52: Line 52:
  
 
=="I cannot import a CSV file generated on Mac"==
 
=="I cannot import a CSV file generated on Mac"==
 +
<u>Problem:</u> I select correct "CSV delimiter", but I continue geting error "The file you are trying to import does not contain any sections" when trying to import my CSV file.
  
Please contact our support team for help.
+
<u>Solution:</u>
 +
If your CSV file was created with Macintosh, it may contain Macintosh EOL characters (\r). These characters are causing the problem.
 +
 
 +
To fix the problem please ask your hosting provider to set the <u>'auto_detect_line_endings'</u> directive to 'On' in 'php.ini' on your server.
 +
 
 +
When this directive is turned on, PHP will examine the data read by fgets() and file() to see if it is using Unix, MS-Dos or Macintosh line-ending conventions.
 +
 
 +
This enables PHP to interoperate with Macintosh systems, but defaults to Off, as there is a very small performance penalty when detecting the EOL conventions for the first line, and also because people using carriage-returns as item separators under Unix systems would experience non-backwards-compatible behavior.
 +
 
 +
{{Note1|Note: This configuration option was introduced in PHP 4.3.0.}}
 +
 
 +
If this does not help, please contact our support team for help.
 +
 
 +
== "During CSV import, data gets truncated after special characters or is not imported at all. / Language file import does not work correctly." ==
 +
 
 +
The following features:
 +
* [[X-Cart:Managing_Languages#Adding_languages|Add/Update language]]
 +
* [[X-Cart:Affiliate#Uploading_Payment_Info|Payment info uploading]]
 +
* [[X-Cart:Import-Export_Guide#Importing_Data|Import data]]
 +
* [[X-Cart:Order_Tracking|Import order tracking numbers]]
 +
* [[X-Cart:Gift_Registry#Recipients_List|Import recipients list for Gift Registry module]]
 +
* [[X-Cart:Managing_Products#Updating_product_quantities_and_prices|Update inventory]]
 +
employ the function http://php.net/fgetcsv which uses the system locale to define the charset of the import file.
 +
 
 +
The problem may be caused by that the charset using which your import CSV file is encoded does not match the system locale.
 +
 
 +
To ensure that the import process works as expected, please check that the charset of any files that are imported using the above features is the same as the system locale.
 +
 
 +
You can find out your system locale using one of the following methods:
 +
* ''(X-Cart 4.6.1 and later)''<br />Look up Server locale info on the Summary page in your store's Admin area (Tools menu -> Summary; In this section: Environment info)
 +
* ''(UNIX systems)''<br />Run the '''locale''' command
 +
* Execute the following PHP command from the command line:<br />php -r 'print_r(setlocale(LC_CTYPE, '0'));'
 +
 
 +
<div id="FastCGI"> </div>
 +
== CSV import times out before completion. Large numbers of duplicate images are populating the /images/D folder. 'Drop' detailed images does nothing.==
 +
 
 +
The import script is likely stopped by a timeout in the image deletion function.
 +
 
 +
The problem may be related to using the FastCGI Apache Module.
 +
If using this module, you have to increase the values of the following settings in the apache/FastCGI configs:
 +
:* [https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidiotimeout FcgidIOTimeout] - The default value of 40 sec is too low for the import procedure;
 +
:* [https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgididletimeout FcgidIdleTimeout] - The default value of 300 sec is too low for the import procedure.
 +
 
 +
How do you know if you are using FastCGI?
 +
 
 +
1. Open phpinfo via the page
 +
https://help.x-cart.com/index.php?title=X-Cart:Summary_Page#Environment_info <br />
 +
2. If you see the following:<br />
 +
::Server API  CGI/FastCGI <br />
 +
::and <br />
 +
::$_SERVER['FCGI_ROLE'] RESPONDER or _ENV["FCGI_ROLE"] RESPONDER <br />
 +
then you are using FastCGI.<br />
  
 
[[Category:X-Cart user manual]]
 
[[Category:X-Cart user manual]]

Latest revision as of 18:06, 14 April 2017

"I cannot import a CSV file I have just exported"

You cannot import a CSV file that you have just exported from your own store. The error message reads:

Error on line 8: The image file pointed to by the filepath in the column 'THUMBNAIL' is not found...

Solution:

If the image(s) causing the problem really need to be imported into the store:

Check the spelling of image filenames/filepaths your CSV file. If the names of the problem image files are specified in your CSV file without a filepath, make sure the field 'Directory where images are located' is not empty and provides a correct path to the image directory. Make sure the images being imported are actually at the location specified by the respective image filepaths.

If importing images was not your intention:

You are probably trying to re-import a file that was exported with the option 'Do you wish to export images?' enabled. On export, your image files were saved to a temporary directory /var/tmp/export_YYYYMMDD_HHMMSS corresponding to the name of the main export file, while the image filenames were written to the export CSV file without filepaths. As you were not going to import images, you probably failed to specify a 'Directory where images are located', which caused the error. To import the CSV file into the store without importing images, remove the column containing image filenames from the CSV file altogether (or create a new export CSV file, this time setting the option 'Do you wish to export images?' to 'No').

"I cannot import a CSV file I have edited in an external editor. The error says "A heading is missing""

You edited your CSV file in an external spreadsheet editor, and now you cannot import it. X-Cart generates an error like this:

Error on line 4: A heading is missing in section "PRODUCTS". (PRODUCTS)

Solution: You probably removed a column in a wrong way or accidentally inserted an extra delimiter symbol in one of the heading rows, which produced a file layout similar to this:

[PRODUCTS]}} {{Note1|!PRODUCTID;;!PRODUCT;!DESCR

(Note the two semicolon characters after !PRODUCTID).

Normally, X-Cart interprets two delimiter symbols following one after another as an empty field; however, the combination must not be used in heading rows like in the example above, as column headings may not be empty. To solve the problem, remove any delimiters leading X-Cart to believe there is an empty column heading.

"I cannot import a CSV file I have edited in an external editor. The error says "Wrong data type""

You edited your CSV file in an external spreadsheet editor, and now you cannot import it. X-Cart generates an error like this:

Error on line 14: Wrong data type: 'PRICE'.

Solution: Check the problem field in your CSV file: something must have got into it that was not supposed to be there. Most probably, a textual value was assigned to a numeric field (For example, the above error could occur if you tried to import a word in the field !PRICE, where a numeric value was expected).

Also note that some spreadsheet editors, like MS Excel, may interpret the format of some data fields wrongly when opening CSV files. This may cause the format of some fields to be corrupted at the time of opening, which, in its turn, may cause problems at the stage of importing. Typically, MS Excel may convert field values written as decimal fractions or as sequences of digits separated by periods to calendar dates. For example, decimal prices like "5.06" or "5.0006" may be converted by MS Excel to "1 May 2006" and "1 May 6" respectively. A code/index like "15.05.06" may also be converted to a calendar date, "15 May 2006". You should be aware of this feature and check CSV files you have opened in a spreadsheet editor very carefully so you do not save corrupted data. If your spreadsheet editor tends to change the format of fields in CSV files as described above, be sure to adjust the format of data presentation for individual cells in your file before the file is opened in your spreadsheet editor.


"I get errors during CSV import"

Attempting to import a CSV file, you get one or more errors of the following type:

Error on line 1: Unknown section name: [ZONES]...
Error on line 4: Unknown section name: [PRODUCTS]...

Solution: Analyze the issue using the scheme below.

Troubleshooting.png

"I cannot import a CSV file generated on Mac"

Problem: I select correct "CSV delimiter", but I continue geting error "The file you are trying to import does not contain any sections" when trying to import my CSV file.

Solution: If your CSV file was created with Macintosh, it may contain Macintosh EOL characters (\r). These characters are causing the problem.

To fix the problem please ask your hosting provider to set the 'auto_detect_line_endings' directive to 'On' in 'php.ini' on your server.

When this directive is turned on, PHP will examine the data read by fgets() and file() to see if it is using Unix, MS-Dos or Macintosh line-ending conventions.

This enables PHP to interoperate with Macintosh systems, but defaults to Off, as there is a very small performance penalty when detecting the EOL conventions for the first line, and also because people using carriage-returns as item separators under Unix systems would experience non-backwards-compatible behavior.

Note: This configuration option was introduced in PHP 4.3.0.

If this does not help, please contact our support team for help.

"During CSV import, data gets truncated after special characters or is not imported at all. / Language file import does not work correctly."

The following features:

employ the function http://php.net/fgetcsv which uses the system locale to define the charset of the import file.

The problem may be caused by that the charset using which your import CSV file is encoded does not match the system locale.

To ensure that the import process works as expected, please check that the charset of any files that are imported using the above features is the same as the system locale.

You can find out your system locale using one of the following methods:

  • (X-Cart 4.6.1 and later)
    Look up Server locale info on the Summary page in your store's Admin area (Tools menu -> Summary; In this section: Environment info)
  • (UNIX systems)
    Run the locale command
  • Execute the following PHP command from the command line:
    php -r 'print_r(setlocale(LC_CTYPE, '0'));'

CSV import times out before completion. Large numbers of duplicate images are populating the /images/D folder. 'Drop' detailed images does nothing.

The import script is likely stopped by a timeout in the image deletion function.

The problem may be related to using the FastCGI Apache Module. If using this module, you have to increase the values of the following settings in the apache/FastCGI configs:

  • FcgidIOTimeout - The default value of 40 sec is too low for the import procedure;
  • FcgidIdleTimeout - The default value of 300 sec is too low for the import procedure.

How do you know if you are using FastCGI?

1. Open phpinfo via the page https://help.x-cart.com/index.php?title=X-Cart:Summary_Page#Environment_info
2. If you see the following:

Server API CGI/FastCGI
and
$_SERVER['FCGI_ROLE'] RESPONDER or _ENV["FCGI_ROLE"] RESPONDER

then you are using FastCGI.