将SQL数据库导出为CSV文件,并与WEKA一起使用 [英] Export a SQL database into a CSV file and use it with WEKA
问题描述
如何将查询结果从.sql数据库导出到.csv文件?我尝试使用
SELECT *
FROM players
INTO OUTFILE'players.csv'
FIELDS TERMINATED BY','
LINES TERMINATED BY';';`
csv文件是这样的:
p1,1,2,3
p2,1,4,5
但它们不在saparated列,都在1列。
我试图自己创建一个.csv文件只是为了尝试WEKA,像:
p1 1 2 3
p2 1 4 5
但WEKA认可 p1 1 2 3
作为单个属性。
那么:如何正确导出一个表从sql db到csv文件?如何使用WEKA?
编辑
添加标题行与列名称?我已经在线阅读,但是我不能。
我使用MySQL 5.5。
您需要通知weka您的csv文件的格式。你可以这样做,打开csv文件和调用选项对话框,请参见下面的图像。此外,您需要使用\\\
而不是;终止您的行。
How can I export a query result from a .sql database into a .csv file? I tried with
SELECT *
FROM players
INTO OUTFILE 'players.csv'
FIELDS TERMINATED BY ','
LINES TERMINATED BY ';';`
and my .csv file is something like:
p1,1,2,3
p2,1,4,5
But they are not in saparated columns, all are in 1 column.
I tried to create a .csv file by myself just to try WEKA, something like:
p1 1 2 3
p2 1 4 5
But WEKA recognizes p1 1 2 3
as a single attribute.
So: how can I export correctly a table from a sql db to a csv file? And how can I use it with WEKA?
EDIT
Is it possible to add a header line with columns names? I have read something online but I am not able.
I'm using MySQL 5.5.
You need to inform weka about format of your csv file. You can do so while opening csv file and invoking options dialog, see below images. Also you need to terminate your lines with "\n" instead of ";".
这篇关于将SQL数据库导出为CSV文件,并与WEKA一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!