通过.CSV文件导入Mysql

发布于 2024-11-03 01:34:36 字数 1061 浏览 0 评论 0 原文

目前有: 将数据本地 INFILE '/Users/RkG/Desktop/Microblogs.csv' INTO TABLE blogs

“导入”

这是我尝试导入的数据的示例。 img2

img3

最后一张图片是我运行的查询的结果,第二张图片是表结构的屏幕截图,为什么它不导入“创建于”、“位置”和“文本”???

通过尝试下面给出的方法,我给出了这个输出:How do I fix this date format?? img

明文:

3,5/18/2011 13:26,42.22717 93.33772,this convention filled with technology could be better don't plan on leaving anytime soon
3,5/10/2011 9:22,42.18881 93.35642,4 orang top scorer skrg  3 di antara nya pake adidas F50 adizero  Lightest fastest deadliest.
3,5/14/2011 9:22,42.22479 93.35922,Nike 'gana' el Mundial al patrocinador oficial Adidas // y eso que sus figuras fueron un fracaso rotundo...
3,5/6/2011 9:22,42.2469 93.32527,Positiiff    mau nabung beli kaos adidas aslii muller .. * basii bgt baru nabung skrg ya  hahaha

Currently have : LOAD DATA LOCAL INFILE '/Users/RkG/Desktop/Microblogs.csv' INTO TABLE blogs

import

This is an example of the data im trying to import.
img2

img3

The last image is a result of the query I ran and the second image is a screenshot of the table structure, why isn't it importing the 'created on', 'location', and 'Text' ???

By trying the method given below I'm giving this output: How do I fix this date format??
img

PLAINTEXT:

3,5/18/2011 13:26,42.22717 93.33772,this convention filled with technology could be better don't plan on leaving anytime soon
3,5/10/2011 9:22,42.18881 93.35642,4 orang top scorer skrg  3 di antara nya pake adidas F50 adizero  Lightest fastest deadliest.
3,5/14/2011 9:22,42.22479 93.35922,Nike 'gana' el Mundial al patrocinador oficial Adidas // y eso que sus figuras fueron un fracaso rotundo...
3,5/6/2011 9:22,42.2469 93.32527,Positiiff    mau nabung beli kaos adidas aslii muller .. * basii bgt baru nabung skrg ya  hahaha

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你又不是我 2024-11-10 01:34:36

假设您将created_at从日期更改为日期时间,这会给您一个想法。
根据您的需要调整日期修饰符(我不知道字符串中的日期和月份顺序)。

load data local infile '/Users/RkG/Desktop/Microblogs.csv'
into table blogs 
fields terminated by ','
lines terminated by '\n'
(id,@created_at,location,text)
set created_at = str_to_date(@created_at,'%c/%d/%Y %k:%i')

如果最后一行对您不起作用,请参阅:

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date

Supposing that you change created_at from date to datetime this would give you an idea.
Adapt date modifiers to your needs (i don't know date and month order in your string).

load data local infile '/Users/RkG/Desktop/Microblogs.csv'
into table blogs 
fields terminated by ','
lines terminated by '\n'
(id,@created_at,location,text)
set created_at = str_to_date(@created_at,'%c/%d/%Y %k:%i')

If that last line does not work for you see:

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date

夜巴黎 2024-11-10 01:34:36

最好尝试此应用程序将 .CSV 或 .XLS 文件直接导入 mysql 数据库 http://bloggerplugnplay.blogspot.in/2013/01/tool-to-import-csv-and-xls-to-mysql.html

better try this application for importing .CSV or .XLS file directly into mysql database http://bloggerplugnplay.blogspot.in/2013/01/tool-to-import-csv-and-xls-to-mysql.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文