What also is being said in the comments, SQLite sees your input as 1, 25, 62, 7. I also had a problem with , and in my case it was solved by changing "separator ," into ".mode csv". So you could try:
sqlite> create table foo(a, b);
sqlite> .mode csv
sqlite> .import test.csv foo
The first command creates the column names for the table. However, if you want the column names inherited from the csv file, you might just ignore the first line.
I am merging info from previous answers here with my own experience. The easiest is to add the comma-separated table headers directly to your csv file, followed by a new line, and then all your csv data.
If you are never doing sqlite stuff again (like me), this might save you a web search or two:
In the Sqlite shell enter:
$ sqlite3 yourfile.sqlite
sqlite> .mode csv
sqlite> .import test.csv yourtable
sqlite> .exit
If you haven't got Sqlite installed on your Mac, run
$ brew install sqlite3
You may need to do one web search for how to install Homebrew.
Here's how I did it.
Enter the sqlite shell of the db to which the data needs to be added
sqlite> .separator "\t" ---IMPORTANT! should be in double quotes
sqlite> .import afile.csv tablename-to-import-to
How to import csv file to sqlite3
Create database
sqlite3 NYC.db
Set the mode & tablename
.mode csv tripdata
Import the csv file data to sqlite3
.import yellow_tripdata_2017-01.csv tripdata
Find tables
.tables
Find your table schema
.schema tripdata
Find table data
select * from tripdata limit 10;
Count the number of rows in the table
select count (*) from tripdata;
before .import command, type ".mode csv"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With