I'm trying to analyze this wiktionary dump with is 5GB, but I'm getting the above error message in the title. Here is my code:
import sqlite3
conn = sqlite3.connect(':memory:')
c = conn.cursor()
sql_file = open(f'wiktionary_categories.sql',encoding = "ISO-8859-1")
sql_as_string = sql_file.read()
c.executescript(sql_as_string)
Is there some way I can use a with statement? Such as:
with open(f'wiktionary_categories.sql',encoding = "ISO-8859-1") as sql_file:
sql_as_string = sql_file.read()
c.executescript(sql_as_string)
I just want to run through the file and pick out all of the words that belong to a certain category.
read()on large files since you read all at once into a single string. Usually, you want to iterate across lines. See I/O docs.