I am trying to figure out an eazy way to load CSV file into SQLite DB using System.Data.SQLite
I saw commandline way to do that i.e .Import mydata.csv mytable
But I need to do this via C# code. Any Idea?
You can import a CSV file into SQLite table by using sqlite3 tool and . import command. This command accepts a file name, and a table name. Here, file name is the file from where the data is fetched and the table name is the table where the data will be imported into.
To copy a table or query to a csv file, use either the \copy command or the COPY command.
you can create OleDbConnection
to CSV file (just google it, it is very easy) then load rows to DataSet, then put that dataset into Sqlite by SqliteConnection
. Few lines of code.
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