NAME
Csvsql – use SQL queries to access information in CSV files
DESCRIPTION
csvsql enables you to access a CSV file as if it were a table in a database. This means you can use SQL queries, with each ’common seperated
value’ as part of a column.
Traditionally in order to access specific information from a CSV file it can take considerable use of regular expressions, awk and sed amongst
others. What if you only wanted to take out a handful of lines from a large file? It nearly becomes easier to do it manually than to figure out
the expressions needed otherwise.
SYNOPSIS
Csvsql [-h] [-v] [-c “command”] [-s seperator] [-p filename] [-l logging]
COMMAND LINE OPTIONS
-h This help message
-v Prints Csvsql version number
-c Run this command and exit. Command should be in “”
-s User defined separator (defaults to , ) if using a space please use ” ”
-p Copy output to a specified file. This option can also be specified in interactive mode.
-l Switch logging on or off. 1 = on, 0 = off (defaults to 1)
INTERACTIVE OPTIONS
SUPPORTED SQL QUERIES
At present the supported queries are:
SELECT
SELECT [ * | select_expr ]
[ FROM file_name [ WHERE where_condition ]
[ LIMIT row_count ] ]
INSERT
INSERT INTO file_name
(col_name,col_name,…)
VALUES (expr,expr,…)
UPDATE
UPDATE file_name
SET col_name=expr
[ WHERE where_condition ]
DELETE
DELETE FROM file_name
WHERE where_condition
CREATE
CREATE file_name
(col_name,col_name,…)
WITH VALUES (expr,expr…)
WHERE
The WHERE clause, if given, indicates the condition or conditions that rows must satisfy to be selected. where_condition is an expression
that evaluates to true for each row to be selected. The statement selects all rows if there is no WHERE clause.
The WHERE clause can be used for selections that include an AND or an OR operator, where AND requires for both conditions to be true, and OR
requires either one or the other.
NON-SQL COMMANDS
open [file_name]
Opens a file and read it’s contents into memory
close [file_name]
Closes the specified file and release all locks. If no file specified will default to the currently opened file.
describe [file_name]
Display a files column headings.
set pipe = [file_name | off]
Will copy output to a specified file. This option can also be specified as a command line option
ls [path]
List specified directory
dir [path]
Same as above
clear
Clear screen
cls Same as above
version
Print version number
dump
Dump a listing of data in memory
SPECIAL VALUES
isnull
In order to check for, or insert a null value, you should use isnull in place of ’’ Example: SELECT * FROM file_name WHERE col_name = isnull
LICENCE
Copyright (C) 2008 Killian Faughnan
CsvSQL is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Soft‐
ware Foundation, either version 3 of the License, or (at your option) any later version.
You should have received a copy of the GNU General Public License along with CsvSQL. If not, see <http://www.gnu.org/licenses>
Author: Killian Faughnan <killian [at] killianfaughnan [dot] com>
<http://www.killianfaughnan.com>
SEE ALSO
For further documentation please see <http://docs.killianfaughnan.com/csvsqldocs>