0

I am using sqlite3 on AWS cloud 9 and want to import a csv file. I first created a table (citites) and then use the following to import file:

.import C:/Users/akima/Documents/SQL/city.csv cities

However I got this error:

Error: cannot open "Users/akima/Documents/SQL/city.csv"
Amir
  • 1,017
  • 4
  • 14
  • 32
  • Possible duplicate of [Import CSV to SQLite](https://stackoverflow.com/questions/14947916/import-csv-to-sqlite) – szmate1618 Nov 02 '18 at 14:22
  • My question is different from the post you mentioned – Amir Nov 02 '18 at 14:38
  • Sorry then, but how is it different exactly? – szmate1618 Nov 02 '18 at 14:42
  • in my case I can not open the csv file in the first place (The error is cannot open the file). In the post you mention the issue is related to mismatching the columns between sexting table and csv file – Amir Nov 02 '18 at 14:45
  • You have a point, but there's a small chance different versions mistakenly report different errors. I'd try to specify .mode and .separator explicitly, just in case. – szmate1618 Nov 02 '18 at 14:58

1 Answers1

0

If the actual path is not C:/Users/akima/Documents/SQL/city.csv and contains spaces enclose it in apostrophes like:
"C:/Users/akima/Documents/SQL/city.csv" or
'C:/Users/akima/Documents/SQL/city.csv'

forpas
  • 160,666
  • 10
  • 38
  • 76
  • 1
    It is the actual path with no spaces. Also I tires it with apostrophes and still get the same error. – Amir Nov 02 '18 at 14:52
  • 1
    And are you sure it's cities.csv and not cities.csv.txt. Annoyingly enough Windows hides common file extensions by default. Also make sure you have read privileges. – szmate1618 Nov 02 '18 at 14:56
  • I can read the same file from python pandas so the file name is correct and I have read privileges as it is my personal account. – Amir Nov 02 '18 at 15:03
  • Ok, I'm just shooting in the dark here but I have another idea. It's a bit suspicious that you specify a path like C:/Users... but the error is reported for Users... It looks like SQLite truncates the path. Does it work if you use a relative path? Or place the csv in the same directory where your sqlite.exe is. – szmate1618 Nov 02 '18 at 15:07
  • I am using AWS cloud 9 so sqlite in on the cloud and not my laptop – Amir Nov 02 '18 at 15:21
  • 1
    So is this folder accessible to AWS cloud 9? – forpas Nov 02 '18 at 15:35