У меня тоже такая же ошибка. Может кто-нибудь, пожалуйста, помогите?
Я изменил каталог на путь, где находится файл и смог прочитать данные. Но когда я использую оператор запроса read sql в pandas, я получаю ошибку. Ниже приведен код ipynb и полученная ошибка.
Код:
import warnings
warnings.filterwarnings("ignore")
import sqlite3
import pandas as pd
import os
#cwd= os.getcwd()
%cd /content/drive/My Drive/Colab Notebooks/
!pwd`enter code here`
секунда ячейка:
from google.colab import drive
drive.mount('/content/drive')
# After executing the cell above, Drive
# files will be present in "/content/drive/My Drive".
!ls "/content/drive/My Drive/Colab Notebooks/Reviews.csv"
Третья ячейка:
con = sqlite3.connect('/content/drive/My Drive/Colab Notebooks/Reviews.csv')
# filtering only positive and negative reviews i.e. not taking into consideration those reviews with Score=3
# SELECT * FROM Reviews WHERE Score != 3 LIMIT 500000, will give top 500000 data points
# you can change the number to any other number based on your computing power
# filtered_data = pd.read_sql_query(""" SELECT * FROM Reviews WHERE Score != 3 LIMIT 500000""", con)
cur = con.cursor()
df_bonus = pd.read_csv('/content/drive/My Drive/Colab Notebooks/Reviews.csv')
print(df_bonus)
filtered_data = pd.read_sql_query(""" SELECT * FROM Reviews WHERE Score != 3 LIMIT 3000""", con)
Сообщение об ошибке:
Id ... Text
0 1 ... I have bought several of the Vitality canned d...
1 2 ... Product arrived labeled as Jumbo Salted Peanut...
2 3 ... This is a confection that has been around a fe...
3 4 ... If you are looking for the secret ingredient i...
4 5 ... Great taffy at a great price. There was a wid...
... ... ... ...
568449 568450 ... Great for sesame chicken..this is a good if no...
568450 568451 ... I'm disappointed with the flavor. The chocolat...
568451 568452 ... These stars are small, so you can give 10-15 o...
568452 568453 ... These are the BEST treats for training and rew...
568453 568454 ... I am very satisfied ,product is as advertised,...
[568454 rows x 10 columns]
---------------------------------------------------------------------------
DatabaseError Traceback (most recent call last)
/usr/local/lib/python3.6/dist-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
1585 try:
-> 1586 cur.execute(*args, **kwargs)
1587 return cur
DatabaseError: file is not a database
The above exception was the direct cause of the following exception:
DatabaseError Traceback (most recent call last)
3 frames
/usr/local/lib/python3.6/dist-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
1596
1597 ex = DatabaseError(f"Execution failed on sql '{args[0]}': {exc}")
-> 1598 raise ex from exc
1599
1600 @staticmethod
DatabaseError: Execution failed on sql ' SELECT * FROM Reviews WHERE Score != 3 LIMIT 3000': file is not a database