Does anyone know of any tools to provide simple, fast queries of flat files using a SQL-like declarative query language? I\'d rather not pay the overhead of loading the file in
We'll I have a lightweight ORM for sqlite that would simplify this task without requiring any configuration files, etc.
If you can using PowerShell has a lot of powerful capabilities for parsing and querying text files (example here). Otherwise using .NET/Mono you can cut that up in and use LINQ in no time.
you can use sqlite. Here's an example using Python.
import sqlite3
conn = sqlite3.connect('/tmp/test.db')
cursor = conn.cursor()
try:
cursor.execute("""create table table1 (word varchar not null, number varchar not null)""")
except: pass
cursor.execute("insert into table1 values ('dog', '15')")
cursor.execute("insert into table1 values ('cat', '20')")
cursor.execute("insert into table1 values ('dog', '10')")
cursor.execute("select max(number) , word from table1 group by word")
print cursor.fetchall()
output
$ ./python.py
[(u'20', u'cat'), (u'15', u'dog')]