Darkrose's Blog
New Project: csvDB
30th October 2011
By: Darkrose
So the other day work I found myself working with a csv file and needing to know what the unique values of on of the columns was... much awk'ing and grep'ing ensued. Having decided this was non optimal I figured I needed to run an sql query on it; which meant creating a database table somewhere, loading the data, then doing the query I want, and finally dropping the table... again non-optimal. So instead I wrote a quick script (in PHP of all things) to parse sql and query the file.
As the day went by I had to do some more queries on the file, and the script grew to add LIMIT and COUNT() and so on... I showed this to a colleague who was generally impressed.
By the time I got home the idea of doing a more complete utility was on my mind... and once I got the basic SQL working the idea of splitting it into a separate library and client had to come into being. This meant doing some more work on the client so it was a bit more than just `command "query"', so the various -f -e -n arguments were added. Then I figured I might as well add a shell, and while I'm at it, might as well give the shell persistant history.
The result of all this, is csvDB: check out it's project page.
There's a fair - but nowhere near complete - subset of SQL available; 'SELECT' for instance is pretty much all there, you just can't use HAVING on GROUP BY, yet. You can however load pretty much any CSV file into csvDB with 'LOAD DATA INFILE', then 'SHOW TABLES' to see what's loaded, 'DROP TABLE' to unload a table, 'DROP PERMANENT TABLE' to unload it and delete the file, and 'DESCRIBE TABLE' to see what columns you've got. I do have plans to keep expanding, eventually adding 'INSERT' and 'DELETE' and so on in order to actually edit files, but this is a good starting point I think. For now, I think I'll just write some doc's for it.
A screenshot of the csvDB shell in action:
As the day went by I had to do some more queries on the file, and the script grew to add LIMIT and COUNT() and so on... I showed this to a colleague who was generally impressed.
By the time I got home the idea of doing a more complete utility was on my mind... and once I got the basic SQL working the idea of splitting it into a separate library and client had to come into being. This meant doing some more work on the client so it was a bit more than just `command "query"', so the various -f -e -n arguments were added. Then I figured I might as well add a shell, and while I'm at it, might as well give the shell persistant history.
The result of all this, is csvDB: check out it's project page.
There's a fair - but nowhere near complete - subset of SQL available; 'SELECT' for instance is pretty much all there, you just can't use HAVING on GROUP BY, yet. You can however load pretty much any CSV file into csvDB with 'LOAD DATA INFILE', then 'SHOW TABLES' to see what's loaded, 'DROP TABLE' to unload a table, 'DROP PERMANENT TABLE' to unload it and delete the file, and 'DESCRIBE TABLE' to see what columns you've got. I do have plans to keep expanding, eventually adding 'INSERT' and 'DELETE' and so on in order to actually edit files, but this is a good starting point I think. For now, I think I'll just write some doc's for it.
A screenshot of the csvDB shell in action:
There are no comments for this blog entry.

![[FSF Associate Member]](http://static.fsf.org/nosvn/associate/fsf-10005.png)
