Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import error -> Row 1 doesn't contain data for all columns #20

Closed
jalogut opened this issue May 15, 2015 · 8 comments
Closed

Import error -> Row 1 doesn't contain data for all columns #20

jalogut opened this issue May 15, 2015 · 8 comments

Comments

@jalogut
Copy link
Contributor

jalogut commented May 15, 2015

I get the following error with all the imports:

SQLSTATE[01000]: Warning: 1261 Row 1 doesn't contain data for all columns

screen shot 2015-05-15 at 18 52 58

I think it is because the "entity_id" column is not into the .csv file and then the number of columns in the temporal table differ with the ones in the source file.

Do you know how can I solve this issue?

@magentix
Copy link
Collaborator

Hello,

"entity_id" field will never be in CSV file, a link between akeneo code and entity id in Magento is done.

In CSV file, is field separator "semi-colon" ? In Magento database, check "tmp_*" table after import failed, and check the columns.

@jalogut
Copy link
Contributor Author

jalogut commented May 27, 2015

Hi,

That is what I meant. If entity_id will never be in CSV file but it is a column on the tmp_* tables, the number of columns do not match. In my case if the columns are not the same I get that error.

Yes, the field separator is a "semi-colon".

screen shot 2015-05-27 at 19 26 43
screen shot 2015-05-27 at 19 26 26

@jalogut
Copy link
Contributor Author

jalogut commented May 27, 2015

I do not know if I am the only one with this problem but if not, a couple of possible solutions I can think about are as follows:

Option 1.- Move addColumn('entity_id' ...) into matchEntity method. That way, the column will not exist at the time loadDataInfile is executed
Option 2.- Specify fields in method loadDataInfile. Passing the fields from the csv header to this method and adding something like that at the end of the $query should work:
IGNORE 1 LINES
(" . preg_replace('/\r|\n/', '', implode(',', $fields)) . ");"

Let me know what you think about that.

@jalogut
Copy link
Contributor Author

jalogut commented Aug 20, 2015

Just in case that someone has the same problem I found a solution for that. It turns out to be a problem of the mysql configuration. The problem comes from STRICT_TRANSTABLES in the sql_mode configuration.

  • Remove that from you my.cnf and restart mysql.

This should fix the issue and the import will then work.

@roman204
Copy link

roman204 commented Oct 1, 2015

@jalogut can confirm that worked... thanks for sharing a solution 👍

@jaswinderahuja
Copy link

Hi @jalogut ,
I am getting same error. but it didn't solved with this solution.
I am trying to remove non-ascii characters from csv file using val.encode("UTF-8", "iso-8859-1") and writing new csv file. then try to import it to mysql.
I checked it seems perfect but getting error.

Mysql2::Error: Row 1 was truncated; it contained more data than there were input columns: LOAD DATA INFILE

@jalogut
Copy link
Contributor Author

jalogut commented Jul 7, 2016

Hi @jaswinderahuja,

Did you remove "strict_trans_tables" sql_mode from your mysql configuration (my.cnf)? That was my problem, nothing to do with the encoding.

@jaswinderahuja
Copy link

jaswinderahuja commented Jul 7, 2016

Hi @jalogut,

yes i removed SRICT_TRANS_TABLES from my.cnf. but issue was with LOAD DATA INFILE ....... LINES TERMINATED BY '\r\n' and in LINUX it was only '\n' so that solved this.

I think reason behind was data and no of columns was mismatching because of this.
As you noticed I was getting more data then column..

Thanks!!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants