小编Cha*_*sEF的帖子

使用phpMyAdmin将CSV文件导入MySQL

我搜索并阅读了许多关于将CSV文件导入MySQL数据库的帖子/文章,phpMyAdmin 2.8.0.1并且它们使声音如此简单,实际上并非如此.我没有做任何事情.

我有一个有2列的表,都定义为NOT NULL.主索引配置为使用两个列.我有很多CSV文件要导入,但我先从小文件开始.以下是我的CSV数据文件示例:

type    description
T   Antarctic Territory
T   Dependency
T   Independent State
T   Proto Dependency
T   Proto Independent State
Run Code Online (Sandbox Code Playgroud)

导入只有17行,但通常我会插入0行,有时我会插入1行,但格式错误.我的意思是第1列为空白,第2列包含两列的数据,顺序错误.这是我的导入尝试生成的SQL:

LOAD DATA LOCAL INFILE '/var/php_sessions/uploads/phpiptDPV' REPLACE INTO TABLE `country_types`
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\r\n'
IGNORE 1
LINES (
`type` ,
`description`
)# MySQL returned an empty result set (i.e. zero rows).
Run Code Online (Sandbox Code Playgroud)

谁能看到我哪里出错了?我花了几天时间研究和尝试不同的东西,但我已经准备好抛出phpMyAdmin了.

mysql csv phpmyadmin

6
推荐指数
2
解决办法
5万
查看次数

正则表达式在每次匹配之前插入字符串

我搜索过并找到了一些解决方案,但它们适用于不同的语言,我无法翻译它们。由于我对此了解甚少,希望向专家求助。这是我的技能所能达到的程度:

到目前为止我的代码:

var str = "Tell us about this interaction. Make sure you mention: (a) what the interaction was about (hangout, chit chat, discuss assignments, etc.) (b) what other things you and/or your friend was doing on the phone during this interaction (c) whether both of you were involved in this other activity and (d) any other information about this interaction you would like to share with us. Avoid using your friends full real name";
var pat = /\([a-zA-Z]\)/g;
var …
Run Code Online (Sandbox Code Playgroud)

javascript regex

6
推荐指数
1
解决办法
1万
查看次数

标签 统计

csv ×1

javascript ×1

mysql ×1

phpmyadmin ×1

regex ×1