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

From X-Cart 4 Classic
Jump to: navigation, search
m
("I cannot import a CSV file generated on Mac")
Line 57: Line 57:
 
If your CSV file was created with Macintosh, it may contain Macintosh EOL characters (\r). These characters are causing the problem.
 
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 'true' in 'php.ini' on your server.
+
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.
 
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.

Revision as of 16:49, 16 December 2013

"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'));'