Home

Carl Burch

txtselect - version 1.0 - Python 2.6 or above (including 3.x)

Project administrator:

Project Admins:

Documentation

Applies a simple SQL query (without joins) to a tab-separated-value text file. As an example, suppose we want to determine the total population for each U.S. state, and we have a file where each line has a county name, the state name, and county population, separated by tabs.

 txtselect 'c2, sum(c3) from county-pops.txt group by c2'

Supported syntax:

[SELECT] expr [, expr ...]
[FROM filename]
[WHERE expr]
[GROUP BY expr [ASC | DESC] [, expr [ASC | DESC] ... ]
[HAVING expr]
[ORDER BY expr [ASC | DESC] [, expr [ASC | DESC] ...]
[LIMIT { count | offset, count | count OFFSET offset }]

Supported operators: ** * / % + - = == != <> < > <= >= not and or
Supported aggregate functions: count, sum, avg, min, max, first, last
Supported scalar functions: abs, bin, ceiling, concat, concat_ws, floor, hex, if, instr, left, length, lower, lpad, ltrim, oct, ord, right, round, rpad, rtrim, space, substr, trim, upper

Copyright

Copyright (c) 2011, Carl Burch. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    THIS SOFTWARE IS PROVIDED BY CARL BURCH ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARL BURCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Change log

version 1.0, 11 Sep 2011 - Carl Burch - initial release


MongoDB Logo MongoDB