Reputation: 57
I'm very new to DQL and sqlite. I've created a very basic database and am trying to import data from a .csv file. I watched a tutorial and have entered the following code:
.import countries.csv countries
This gives the following error:
Error: cannot open "countries.csv"
I'm sure im over looking something easy here. countries.csv is a file I made in excel and saved as a .csv. In Text Editor it opens as a normal comma seperated values file
Upvotes: 1
Views: 12284
Reputation: 1
Oh! It took me few hours to solve the problem and it nearly drove me mad! I had saved the csv file in a folder while I didn't change the terminal into it. I used cs50ide and after I typed in 'cd folder/' and then tryed again, it worked. Hope this can help u.
Upvotes: -1
Reputation: 41
You need to escape the backslash by using doubles. I've had success using two backslashes in the path when doing this on Windows.
Try this out:
sqlite> .import "C:\\working\\tmp\\data.txt" tablename
Upvotes: 4
Reputation: 57
For anyone with the same problem - any path that contains spaces needs to use quotation marks
Upvotes: 3