我正在尝试将mysql数据库转换为csv格式,我想使用pandas读取那些转换后的文件,但显示如下错误: EmptyDataError:没有要从文件中解析的列, 我正在使用pychram 3.6, 请提前告诉我有关此问题的信息
这是我的代码:
import MySQLdb as dbapi
import sys
import csv
import mysql.connector
import pandas as pd
import MySQLdb as dbapi
import mysql
import sys
import csv
from pandas import Series
from matplotlib import pyplot
import mysql.connector
import pandas as pd
from matplotlib import pyplot
from pandas import Series
from statsmodels.tsa.stattools import adfuller
from matplotlib import pyplot
from pandas import DataFrame
from pandas import read_csv
conn = mysql.connector.connect(
user='root',
password='',
host='127.0.0.1',
database='production_db')
cur = conn.cursor(buffered=True)
query="""
SELECT CAST(orders.`created_at` AS DATE) AS order_date, SUM(total) AS
order_total FROM orders
INNER JOIN sites ON orders.`site_id` = sites.id
INNER JOIN users ON orders.`user_id` = users.`id`
WHERE orders.site_id = 63 AND order_number > 0 AND users.email NOT LIKE
'%@costprize.com'
AND users.email NOT LIKE '%@gito.me' AND orders.`status` !=
'CART_INPROGRESS' AND orders.`status` != 'CANCELLED'
GROUP BY CAST(orders.`created_at` AS DATE) ORDER BY order_date ASC
"""
cur.execute(query)
result = cur.fetchall()
c = csv.writer(open('dataset.csv', 'w'))
for x in result:
c.writerow(x)
df = pd.read_csv('dataset.csv')
print (df.shape)