CSV file import MySQL do I need to create a new table? workaround
Source: Internet
Author: User
CSV file import MySQL do I need to create a new table?
I have a CSV file that needs to be imported into MySQL, whether it is necessary to build a table first, and then in the new field, I have tried to build a table, also built a field, and then import with phpMyAdmin, and then error, the message is Invalid field count in CSV input on line 1.
Do not know why ~ ask Daniel to answer me this just started, thank you
Oops, can not insert attachment picture, just can have outside chain ... Not a pit daddy?
------Solution--------------------
$con = mysql_connect ("localhost", "Peter", "abc123");
if (! $con)
{
Die (' Could not connect: '. Mysql_error ());
}
Create table
mysql_select_db ("my_db", $con);
mysql_query ("SET NAMES UTF8");
$sql = "CREATE Table table name
(
PartyID varchar (60),
Full NAME varchar (100),
Local NAME varchar (100),
... all columns in the//CVS
)";
Execute Query
mysql_query ($sql, $con);
Mysql_close ($con);
?>
------Solution--------------------
Invalid field count in CSV input on line 1.
The CSV input field number on line 1 is inefficient.
Confirm that the data type of the column is correct!
The first row (header row) should be skipped when importing
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service