Large SQL file to CSV file

Viewed 434

I downloaded a large dataset (compressed file 17G (.sql file)) and I want to convert it to csv or import in jupyter notebook.

I tried this code:

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()

but I get an error :

DatabaseError
Traceback (most recent call last)
in
8 cursor = connection.cursor()
9 # Execute the query
10 cursor.execute('select * from steam')
11 # Get data in batches
12 while True:

DatabaseError: file is not a database

The dataset is from https://steam.internet.byu.edu/#

Please - how can I do this?

I need some of this data in my project

0 Answers
Related