Restructuring and Next Project

So since I am lazy and obviously not going to do a new post a week, I am changing the tone of this blag to “Thing Every Once in a While”.  That way I am not creating false expectations for myself/my faithful viewers.

My next project I’ve been wanting to work on is as follows: a unix tool which allows one to query a file as if it were a database.  It would only implement simple operations, but that’s all I ever find myself needing to do on a file anyhow.  Instead of actually updating the file, it would just output the updated information which could be used to replace the file (as most unix tools work anyhow).

One of the issues I’ve been trying to figure out is usage/invocation.  I’ve talked myself into putting all the “select” criteria onto the command line as arguments, but I can’t think of a clean way of pulling it off.  An example of what I have in mind:

filesql -d',' update set -f3 = "new value" where -f1 -eq "asdf" and -f2 -ne -f4 <input.csv >output.csv

If anyone else has a better idea for a “usage” paradigm, please let me know.

3 Comments

  1. Sujit Sudhi Says:

    I think its a super good idea. Can’t wait to start using it!

  2. miked Says:

    This seems like a really cool idea, I’m interested to see how you’ll pull it off. :)

    Is there a reason you’re prefering to use a lot of command-line arguments instead of just to wrapping the SQL query in quotes? For instance, something closer to this:
    filesql “update input.csv set * = ‘new value’ where * = ‘asdf’” >> output.csv

  3. Josh Says:

    Mike,

    There were two reasons I chose this paradigm:
    1) It closely mimics the usage of other UNIX utilities (most notably “find”).
    2) I don’t have to do my own tokenizing.

    If this turns out to be something people actually use, then I can see doing quoted SQL (or syntax close to SQL).

Leave a Comment