tags:

views:

753

answers:

9

I have a bunch of pretty large CSV (comma separated values) files and I want to analyze them. SQL queries are ideal for this. So far I have been using MS Access to import the CSV files and execute queries on them. However, in addition to having a very bad SQL editor and having stupid arbitrary rules about when a query/table can be opened/edited/deleted, it is extremely slow. I can live with initial slowness when executing a query, but I really hate that it seems to re-execute it whenever I try to sort the table on another column, wait 5 minutes, or try to scroll.

Are there any better (free) tools for the job? (I would be willing to manually write a script to transform the CSV into something else if required)

Thanks!

Edit: Thanks for all the answers! I'm going to try out SQL Server and if it works out, I'll accept that answer. Just a clarification: importing the data file is not necessarily a problem for me (although easy ways to do this are of course welcome). What I need is some program that subsequently allows me to quickly and efficiently execute (reasonably complex) queries on it. FileHelpers isn't going to help me, because first of all I don't know any .NET languages and second of all, I had the data in Java, but I thought analyzing it would be a lot easier with SQL. Thanks for the answer though!

+4  A: 

Why don't just import them to MySQL, it's easy.

LOAD DATA LOCAL INFILE 'file.csv' 
INTO TABLE some_table 
FIELDS TERMINATED BY ',' 
LINES TERMINATED BY '\n' 
(field1, filed2, field3);

And then you can easilly run queries of any complexity...

cleg
You might want to change that to TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'or else you might end up with quotes in your data
Eli
+3  A: 

SQL Server Express 2008 with Tools Here. It includes Management Studio and it works great.

Note that it does require .net framework 3.5 sp1, MS Installer 4.5 and Powershell 1.0, but there are links on the download page if you need to get those as well.

rjrapson
Oh, how Microsoft likes to wrap those little tentacles around us ...
le dorfier
+2  A: 

You did not say what DBMS you use but PostgreSQL has a COPY command to do so, with many options:

COPY billing.contact FROM '/foo/bar/contact.csv' WITH DELIMITER AS ',';
bortzmeyer
+1  A: 

Thinking slightly out of the box, you might look at LINQ to CSV.

ctacke
Doesn't LINQ require .net? Don't kill me if I'm way off... just know that's how the guys around me use it.
A: 

If you would like to perform some processing on the data, I can recommend the FileHelpers library at http://www.filehelpers.com/. It includes pretty much all you need to import, process and export delimited or fixed-length data files.

You could use SQL Server Express as your free DB in place of Access. Read about it here:

http://www.microsoft.com/express/sql/default.aspx

You can use SQL Server's Management Studio Express to query your data, or alternatively you can access many of the same tools through the Visual Studio Express editions, all of which are free - you can even create new MDFs through the Add New Item menu option.

I hope this helps.

Dave R.
+1  A: 

there's also an Oracle Express Edition.

I guess it depends on where you are already proficient. Or maybe where you want to be proficient.

A: 

If you can get them as far as Access, then just export the Access tables to SQL Server. Or, if there's a common schema for the csv, create the table is SQL Server, remotely attach from Access, and import directly into SQL Server.

le dorfier
A: 

logparser can do it... you can create sql queries on csv and other delimited files

Toad
A: 

Oracle SQL Developer (and Oracle Express Edition - thanks Mark) are both free, lightweight and SQl Developer can load csv files into a full relation db: Oracle XE> You can then run SQL statements or even create them through a drag and drop interface. You might also look at Squirrel

Joe