本文介绍了csv从unicode导入到utf8 phpmyadmin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一些汉字导入MySQL数据库。但是一些内容被省略,一些显示无意义。如下图所示:



数据库中有什么:





excel文件中有什么:





谢谢!



您好,这里是附加信息:



文本文档

 巴掌bāzhang(一掌)掌打人类活动
巴掌bāzhang b $ b巴掌bāzhang(一拍)手掌揍打人类活动
把bá工具和物品用把手扫帚扫帚工具
把bá工具和物体与手柄锁锁人造

显示创建表

  CREATE TABLE`table 1`(
`CL_in_Character` varchar(10)CHARACTER SET utf8 DEFAULT NULL,
`CL_in_Pinyin` varchar(14)CHARACTER SET utf8 DEFAULT NULL,
`定义_in_Dictionary` varchar(74)CHARACTER SET utf8 DEFAULT NULL,
`Associated_nouns_in_Chinese` varchar(16)CHARACTER SET utf8 DEFAULT NULL,
`Associated_nouns_in_English` varchar(38)CHARACTER SET utf8 DEFAULT NULL,
`Associated_noun_categories` varchar(38)CHARACTER SET utf8 DEFAULT NULL
)ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci


  LOAD DATA INFILE'/path/to/your/file.csv'INTO TABLE`table 1`
CHARACTER SET'utf8'
FIELDS TERMINATED BY','OPTIONALLY ENCLOSED BY''
由'\\\
'终止的行
IGNORE 1 LINES

通过格式化为CSV我的意思是

 
CL_in_Character,CL_in_Pinyin,Definition_in_Dictionary,Associated_nouns_in_Chinese,Associated_nouns_in_English,Associated_noun_categories
巴掌,bāzhang,手掌掌,打,打,人类活动
巴掌,bāzhang, )棕榈,扇,屁股,人类活动
巴掌,bāzhang,
把,bá,工具和对象与句柄,扫帚,扫帚,工具
把,bá让我们试试看吧







$ b $ p

 
mysql> CREATE TABLE`table 1`(
- >`CL_in_Character` varchar(10)CHARACTER SET utf8 DEFAULT NULL,
- >`CL_in_Pinyin` varchar(14)CHARACTER SET utf8 DEFAULT NULL,
- >`Definition_in_Dictionary` varchar(74)CHARACTER SET utf8 DEFAULT NULL,
- >`Associated_nouns_in_Chinese` varchar(16)CHARACTER SET utf8 DEFAULT NULL,
- >`Associated_nouns_in_English` varchar(38)CHARACTER SET utf8 DEFAULT NULL,
- >`Associated_noun_categories` varchar(38)CHARACTER SET utf8 DEFAULT NULL
- >)ENGINE = InnoDB DEFAULT CHARSET = utf8 COLLATE = utf8_unicode_ci;
查询OK,0 rows affected(0.03 sec)

mysql> LOAD DATA INFILE'/tmp/utf.csv'INTO TABLE`table 1`
- > CHARACTER SET' utf8'
- > FIELDS TERMINATED BY','OPTIONALLY ENCLOSED BY'
- > LINES TERMINATED BY'\\\
'
- > IGNORE 1 LINES;
Query OK ,5 rows affected(0.00 sec)
Records:5 Deleted:0 Skipped:0 Warnings:0

mysql> select * from`table 1`;
+ --- -------------- + -------------- + -------------------- ------------- + ----------------------------- + ------ ----------------------- + -------------------------- - +
| CL_in_Character | CL_in_Pinyin | Definition_in_Dictionary | Associated_nouns_in_Chinese | Associated_nouns_in_English | Associated_noun_categories |
+ ----------------- + ------- ------- + --------------------------------- + -------- --------------------- + ---------------------------- - + ---------------------------- +
|巴掌|bāzhang|(掌声)掌|打|节拍|人类活动|
|巴掌| bāzhang| (一掌的掌)|扇| spank |人类活动|
|巴掌| bāzhang| (一掌的掌)|揍|命中|人类活动|
|把| bá|工具和对象与句柄|扫伞|扫帚|工具|
|把| bá|工具和对象与句柄|锁|锁|人造!
+ ----------------- + -------------- + ------------ --------------------- + ---------------------------- - + ----------------------------- + ------------------ ---------- +
集合中的5行(0.00秒)


I want to import some Chinese Characters into the MySQL database. But some of the content is omitted, and some is showing non-sense. With the pictures shown below:

What's in the database:

What's in the excel file:

Thank you!

Hi, here is the addtional information:

text document

巴掌  bāzhang (a slap of the) palm     打  beat    human activities
巴掌  bāzhang (a slap of the) palm     搧  spank   human activities
巴掌  bāzhang (a slap of the) palm     揍  hit human activities
把   bá  tools and objects with a handle 扫帚  broom   tools
把   bá  tools and objects with a handle 锁   lock    man-made

show create table

CREATE TABLE `table 1` (
 `CL_in_Character` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
 `CL_in_Pinyin` varchar(14) CHARACTER SET utf8 DEFAULT NULL,
 `Definition_in_Dictionary` varchar(74) CHARACTER SET utf8 DEFAULT NULL,
 `Associated_nouns_in_Chinese` varchar(16) CHARACTER SET utf8 DEFAULT NULL,
 `Associated_nouns_in_English` varchar(38) CHARACTER SET utf8 DEFAULT NULL,
 `Associated_noun_categories` varchar(38) CHARACTER SET utf8 DEFAULT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
解决方案

I can't tell about open document format and phpmyadmin, but you can successfully import your data properly formatted as CSV with

LOAD DATA INFILE '/path/to/your/file.csv' INTO TABLE `table 1`
CHARACTER SET 'utf8'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES

By properly formatted as CSV I mean

CL_in_Character,CL_in_Pinyin,Definition_in_Dictionary,Associated_nouns_in_Chinese,Associated_nouns_in_English,Associated_noun_categories
"巴掌","bāzhang","(a slap of the) palm","打","beat","human activities"
"巴掌","bāzhang","(a slap of the) palm","搧","spank","human activities"
"巴掌","bāzhang","(a slap of the) palm","揍","hit","human activities"
"把","bá","tools and objects with a handle","扫帚","broom","tools"
"把","bá","tools and objects with a handle","锁","lock","man-made"

Let's try it

mysql> CREATE TABLE `table 1` (
    ->  `CL_in_Character` varchar(10) CHARACTER SET utf8 DEFAULT NULL,
    ->  `CL_in_Pinyin` varchar(14) CHARACTER SET utf8 DEFAULT NULL,
    ->  `Definition_in_Dictionary` varchar(74) CHARACTER SET utf8 DEFAULT NULL,
    ->  `Associated_nouns_in_Chinese` varchar(16) CHARACTER SET utf8 DEFAULT NULL,
    ->  `Associated_nouns_in_English` varchar(38) CHARACTER SET utf8 DEFAULT NULL,
    ->  `Associated_noun_categories` varchar(38) CHARACTER SET utf8 DEFAULT NULL
    ->  ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Query OK, 0 rows affected (0.03 sec)

mysql> LOAD DATA INFILE '/tmp/utf.csv' INTO TABLE `table 1`
    -> CHARACTER SET 'utf8'
    -> FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
    -> LINES TERMINATED BY '\n'
    -> IGNORE 1 LINES;
Query OK, 5 rows affected (0.00 sec)
Records: 5  Deleted: 0  Skipped: 0  Warnings: 0

mysql> select * from `table 1`;
+-----------------+--------------+---------------------------------+-----------------------------+-----------------------------+----------------------------+
| CL_in_Character | CL_in_Pinyin | Definition_in_Dictionary        | Associated_nouns_in_Chinese | Associated_nouns_in_English | Associated_noun_categories |
+-----------------+--------------+---------------------------------+-----------------------------+-----------------------------+----------------------------+
| 巴掌            | bāzhang      | (a slap of the) palm            | 打                          | beat                        | human activities           |
| 巴掌            | bāzhang      | (a slap of the) palm            | 搧                          | spank                       | human activities           |
| 巴掌            | bāzhang      | (a slap of the) palm            | 揍                          | hit                         | human activities           |
| 把              | bá           | tools and objects with a handle | 扫帚                        | broom                       | tools                      |
| 把              | bá           | tools and objects with a handle | 锁                          | lock                        | man-made                   |
+-----------------+--------------+---------------------------------+-----------------------------+-----------------------------+----------------------------+
5 rows in set (0.00 sec)

这篇关于csv从unicode导入到utf8 phpmyadmin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 19:02