PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 31, 2022

[FIXED] Invalid field count in CSV input on line 1

 January 31, 2022     csv, import, load-data-infile, mysql, phpmyadmin     No comments   

Issue

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


Solution

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.



Answered By - Gareth
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing