How to import csv to MySQL?

pemoch's profile image pemoch posted 2 years ago in General Permalink

How to import csv to MySQL?

CREATE TABLE `prisoners` (
 `id` INT(11) NOT NULL AUTO_INCREMENT,
 `first_name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
 `last_name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
 `middle_name` CHAR(50) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
 `fio` VARCHAR(150) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
 `description` TEXT NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
 PRIMARY KEY (`id`) USING BTREE
)
COLLATE='latin1_swedish_ci'
ENGINE=MyISAM
ROW_FORMAT=DYNAMIC
AUTO_INCREMENT=5
;

Error Message:
"The file was imported, but the server returned 64
warnings and/or comments. For more
information, see the log panel."

SELECT  `id`,  `first_name`,  `last_name`,  `middle_name`,  `fio`, LEFT(`description`, 256) FROM `camp43`.`prisoners` LIMIT 1000;
/* Converting filename to 8.3 format: f:\БД\ФИО\Русс\fio_2.csv => f:\CAB6~1\2C0B~1\574F~1\fio_2.csv */
LOAD DATA LOW_PRIORITY LOCAL INFILE 'f:\\CAB6~1\\2C0B~1\\574F~1\\fio_2.csv' IGNORE INTO TABLE `camp43`.`prisoners` CHARACTER SET utf8 FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY ';' ESCAPED BY '"' IGNORE 1 LINES (`first_name`, `last_name`, `middle_name`, `fio`, `description`);
/* 199 rows imported in 0,016 seconds. */
SHOW WARNINGS;
/* Warning (1265): Data truncated for column 'first_name' at row 1 */
/* Warning (1261): Row 1 doesn't contain data for all columns */
/* Warning (1261): Row 1 doesn't contain data for all columns */
/* Warning (1261): Row 1 doesn't contain data for all columns */
/* Warning (1261): Row 1 doesn't contain data for all columns */
/* Warning (1265): Data truncated for column 'first_name' at row 3 */
/* Warning (1261): Row 3 doesn't contain data for all columns */
/* Warning (1261): Row 3 doesn't contain data for all columns */
/* Warning (1261): Row 3 doesn't contain data for all columns */
/* Warning (1261): Row 3 doesn't contain data for all columns */
/* Warning (1265): Data truncated for column 'first_name' at row 5 */
/* Warning (1261): Row 5 doesn't contain data for all columns */
/* Warning (1261): Row 5 doesn't contain data for all columns */
/* Warning (1261): Row 5 doesn't contain data for all columns */
/* Warning (1261): Row 5 doesn't contain data for all columns */
/* Warning (1265): Data truncated for column 'first_name' at row 7 */
/* Warning (1261): Row 7 doesn't contain data for all columns */
/* Warning (1261): Row 7 doesn't contain data for all columns */
/* Warning (1261): Row 7 doesn't contain data for all columns */
/* Warning (1261): Row 7 doesn't contain data for all columns */
/* Warning (1265): Data truncated for column 'first_name' at row 9 */
/* Warning (1261): Row 9 doesn't contain data for all columns */
/* Warning (1261): Row 9 doesn't contain data for all columns */
/* Warning (1261): Row 9 doesn't contain data for all columns */
/* Warning (1261): Row 9 doesn't contain data for all columns */
/* Warning (1265): Data truncated for column 'first_name' at row 11 */
/* Warning (1261): Row 11 doesn't contain data for all columns */
/* Warning (1261): Row 11 doesn't contain data for all columns */
/* Warning (1261): Row 11 doesn't contain data for all columns */
/* Warning (1261): Row 11 doesn't contain data for all columns */
/* Warning (1265): Data truncated for column 'first_name' at row 13 */
/* Warning (1261): Row 13 doesn't contain data for all columns */
/* Warning (1261): Row 13 doesn't contain data for all columns */
/* Warning (1261): Row 13 doesn't contain data for all columns */
/* Warning (1261): Row 13 doesn't contain data for all columns */

image description image description image description image description image description image description image description image description

pemoch's profile image pemoch posted 2 years ago Permalink

File to export

1 attachment(s):
ansgar's profile image ansgar posted 2 years ago Permalink

Your file has control characters which you did not correctly specify in the dialog.

Examining your file, I suppose these should be correct:

Description

Please login to leave a reply, or register at first.