Index of /~lukewarm/software/csvq

[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -
[TXT]README.html27-Mar-2006 19:36 1.7K
[TXT]csvq.py27-Mar-2006 16:53 5.8K

usage: csvq.py [OPTIONS] [FILE]

Query a CSV (Comma Separated Value) file in SQL fashion. Reads from standard
in if no file specified.

options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -d DELIM, --delim=DELIM
                        Use specified delimiter, \t for TAB, COMMA is default
  -H HEADERS, --headers=HEADERS
                        Specify column headers, COMMA separated, otherwise use
                        first row
  -s SELECT, --select=SELECT
                        Select clause, COMMA separated column names, otherwise
                        select all columns
  -w WHERE, --where=WHERE
                        Where clause (int,float,date,datetime,bool,<,>,==) or
                        any Python statement


The "where" clause can use any arbitrary Python expression which should
evaluate to True or False. For every row, you have access to a String
variable named for each column. For data comparisons, wrap values with
`int`, `float`, `bool`, etc. There are convenience wrappers `date` and
`datetime` which try to coerce data to a DateTime object.

Sample CSV:

NAME,AGE,BIRTH,COUNTRY,GPA
Dave,26,1979-02-12,United States,3.75

csvq.py -w 'int(AGE) > 18' foo.csv
csvq.py -w 'date(BIRTH).year == 1979' foo.csv
csvq.py -w 'COUNTRY in ("United States","Canada","Mexico")' foo.csv
csvq.py -w 'round(float(GPA)) == 4.0' foo.csv
csvq.py -s NAME,BIRTH -w 'date(BIRTH).month = 2' foo.csv


(C)2006 David A. Riggs <david a riggs at gmail dot com>

http://gl1tch.com/~lukewarm/software/csvq/

csvq is licensed under the GNU GPLv2.