Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将大型SQL文件转换为CSV文件_Python_Sql_Database_Csv_Dataset - Fatal编程技术网

Python 将大型SQL文件转换为CSV文件

Python 将大型SQL文件转换为CSV文件,python,sql,database,csv,dataset,Python,Sql,Database,Csv,Dataset,我下载了一个大型数据集压缩文件17G.sql文件,我想将其转换为csv或导入jupyter笔记本 我尝试了以下代码: import sqlite3 import pandas as pd # Open the file f = open('output.csv', 'w') # Create a connection and get a cursor connection = sqlite3.connect('steam.sql') cursor = connection.cursor() #

我下载了一个大型数据集压缩文件17G.sql文件,我想将其转换为csv或导入jupyter笔记本

我尝试了以下代码:

import sqlite3
import pandas as pd
# Open the file
f = open('output.csv', 'w')
# Create a connection and get a cursor
connection = sqlite3.connect('steam.sql')
cursor = connection.cursor()
# Execute the query
cursor.execute('select * from steam')
# Get data in batches
while True:
    # Read the data
    df = pd.DataFrame(cursor.fetchmany(1000))
    # We are done if there are no data
    if len(df) == 0:
        break
    # Let's write to the file
    else:
        df.to_csv(f, header=False)

# Clean up
f.close()
cursor.close()
connection.close()
但我有一个错误:

数据库错误 回溯最近一次通话 在里面 8 cursor=connection.cursor 9执行查询 10.执行“从蒸汽中选择* 11批量获取数据 12尽管如此:

DatabaseError:文件不是数据库

数据集来自

求你了-我该怎么做


如果数据集是一个.sql文件,我需要在我的项目中使用一些数据

,您可能需要执行该文件,以便它创建/填充database@HoneyBadger你能告诉我如何执行该文件吗???我不知道该文件,所以我不知道它需要什么数据库。如果数据集是一个.sql文件,大概您需要执行该文件,以便它创建/填充database@HoneyBadger你能告诉我如何执行这个文件吗???我不知道这个文件,所以我不知道它需要什么数据库。