Simple, fast SQL queries for flat files

前端 未结 8 892
广开言路
广开言路 2021-02-04 07:24

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

相关标签:
8条回答
  • 2021-02-04 08:11

    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.

    0 讨论(0)
  • 2021-02-04 08:14

    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')]
    
    0 讨论(0)
提交回复
热议问题