Import shows error message "Column names have duplicates" but I don't have any duplicates.
Who can I fix this?
"_type","sku","has_options","name","image","small_image","thumbnail","url_key","url_path","price","manufacturer","status","tax_class_id","visibility","description","short_description","gift_message_available","qty","min_qty","is_qty_decimal","backorders","min_sale_qty","max_sale_qty","is_in_stock","notify_stock_qty","manage_stock","qty_increments","enable_qty_increments"
"simple","1174407","0","BCI-15BK Tintenpatrone schwarz","","","","","","22.000","Canon","Enabled","none","Catalogue,Search","BCI-15BK Tintenpatrone schwarz, 2er-Pack, für I70 NSTintenpatronenOriginalML","BCI-15BK Tintenpatrone schwarz, 2er-Pack, für I70 NSTintenpatronenOriginalML","","0","","","0","1","","","","","","0"
I made sure all of my fields also exist in exported csv. Am I missing some required rows? I tried to check but this wiki page from 2012 requires columens that are not even in the exported file. So I am not sure what are the required columens.
PHP Version is 5.2.17
Best Answer
The exception with the error message you stated is triggered in exactly one place (code slightly truncated for readability):
This means,
count(array_unique($this->_colNames))
must be unequal to$this->_colQuantity
The
$_colNames
array is set inMage_ImportExport_Model_Import_Adapter_Csv::rewind()
(which is called during_init()
.Once again, the code is slightly truncated for readability:
The
$_delimiter
is set to,
, the$_enclosure
is set to"
.To try to reproduce the issue, if I copy the CSV extract from your question into a file called test.csv and run the following code:
it produces the following output:
This means, your CSV file is fundamentally okay. The difference must be somewhere else.
Looking at how
array_unique
works, there is a note how the type handling of array elements changed in PHP 5.2.9: http://php.net/manual/en/function.array-unique.php#refsect1-function.array-unique-changelogTo reproduce the issue, I re-ran my test-script with the
SORT_REGULAR
option set, but this still gives the same result (which is logical, since reading a file only can give string values).At this time I believe the difference must be in the CSV file you are using. The Unix and the Windows newline characters (
\n
and\r\n
) are both recognized by thefgetcsv()
command, but the old MacOS style newline character (\r
) would actually lead to the behavior you are experiencing.I can't know if that is the reason why you are experiencing the issue, but I suggest you check the CSV file (again). It might also help if you provide a download link somewhere to the unmodified file (no pastebin), so any non-printable characters are preserved.
It might also help if you post the PHP version you are using.