Is there any way to quickly import data from a .csv or tab delineated .txt into a SQL Compact Edition 3.5 Table?
I have a large amount of data that is impractical for manual input.
I know I can use the BULK INSERT function if I wanted to import into a Server Based SQL Database, but this method does not work in SQL CE.
I use visual studio 2010 and I have SQL Server Management Studio installed.
Any help will be appreciated!
querycsv.py is a Python module and program that allows you to execute SQL code against data contained in one or more comma-separated-value (CSV) files. The output of the SQL query will be displayed on the console by default, but may be saved in a new CSV file.
Microsoft SQL Server Compact (SQL CE) is a compact relational database produced by Microsoft for applications that run on mobile devices and desktops. It includes both 32-bit and 64-bit native support. SQL CE targets occasionally connected applications, and applications with an embedded database.
You can use my VS Add-in, which generates INSERT statements based on a CSV file: http://sqlcetoolbox.codeplex.com
Maybe simpler is better. Nothing easier than your own code which can be expanded very easily. You could even have it build the table dynamically if you wanted but probably not necessary.
var stuff = from l in File.ReadLines(filename)
let x = l.Split(new [] {',', ' '}, StringSplitOptions.RemoveEmptyEntries)
.Skip(1)
.Select(s => int.Parse(s))
select new
{
Sum = x.Sum(),
Average = x.Average()
};
see: Read Csv using LINQ
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