Invalid field count in CSV input on line 1
Solution 1
If you want this to import into that table you have 2 choices:
1) Add a comma before and after the data in every row of your file, or
2) Delete the first and third columns in your table, import the data and then add the 2 columns you deleted back.
Solution 2
If you use phpMyAdmin, then you are allowed to specify column names. When logged into the desired database:
- Select the table you want to import to.
- Click the Import tab.
- Under Format of imported file, select CSV.
- In Column names, write out a comma separated list of the columns you want the data imported to.
You can also use mysqlimport if you prefer the shell.
For Example:
shell>mysqlimport --columns=column1,column2 dbname imptest.txt
Solution 3
In Excel I saved the file as "Microsoft Office Excel Comma Separated Values File (.csv)"
In Phpmyadmin:
- Select database you want to import table into.
- Click import tab.
- Select your file. Set FORMAT to CSV
- Leave Format-Specific Options alone except for ticking the "The first line of the file contains the table column names" box if you need to
- Click GO
- You then need to rename the table ( which will be called somthing like "TABLE 5" if its the 5th table in the DB). So select the table and using the Operations tab -> "Rename table to:"
user455318
Updated on July 09, 2022Comments
-
user455318 almost 2 years
I am trying to export an ODS file to CSV, but when I import into phpmyadmin - I get "Invalid field count in CSV input on line 1."
File (it has more than two lines but the scheme is the same):
"Administração da Guarda Nacional Republicana" "Administração de Publicidade e Marketing"
table:
CREATE TABLE IF NOT EXISTS `profession` ( `id_profession` int(11) NOT NULL, `profession` varchar(45) DEFAULT NULL, `formation_area_id_formation_area` int(11) NOT NULL, PRIMARY KEY (`id_profession`), UNIQUE KEY `profession_UNIQUE` (`profession`), KEY `fk_profession_formation_area1` (`formation_area_id_formation_area`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
I never do something similar, probably i need to specify the columns. the csv only have one column and the table have three. In this case the file input belongs to profession column
-
Admin almost 13 yearsObviously, the data is in the wrong format, and required fields are missing. You can't import it.
-
OMG Ponies almost 13 years
-
user455318 almost 13 yearsso, i can't import a specific column? must be the three fields in this case?
-