Debian Codegraph @

docs/scripts/csvjoin.rst

raw
1 =======
2 csvjoin
3 =======
4
5 Description
6 ===========
7
8 Merges two or more CSV tables together using a method analogous to SQL JOIN operation. By default it performs an inner join, but full outer, left outer, and right outer are also available via flags. Key columns are specified with the -c flag (either a single column which exists in all tables, or a comma-separated list of columns with one corresponding to each). If the columns flag is not provided then the tables will be merged "sequentially", that is they will be merged in row order with no filtering:
9
10 .. code-block:: none
11
12 usage: csvjoin [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b]
13 [-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-L LOCALE]
14 [-S] [--blanks] [--null-value NULL_VALUES [NULL_VALUES ...]]
15 [--date-format DATE_FORMAT] [--datetime-format DATETIME_FORMAT]
16 [-H] [-K SKIP_LINES] [-v] [-l] [--zero] [-V] [-c COLUMNS]
17 [--outer] [--left] [--right] [-y SNIFF_LIMIT] [-I]
18 [FILE [FILE ...]]
19
20 Execute a SQL-like join to merge CSV files on a specified column or columns.
21
22 positional arguments:
23 FILE The CSV files to operate on. If only one is specified,
24 it will be copied to STDOUT.
25
26 optional arguments:
27 -h, --help show this help message and exit
28 -c COLUMNS, --columns COLUMNS
29 The column name(s) on which to join. Should be either
30 one name (or index) or a comma-separated list with one
31 name (or index) per file, in the same order in which
32 the files were specified. If not specified, the two
33 files will be joined sequentially without matching.
34 --outer Perform a full outer join, rather than the default
35 inner join.
36 --left Perform a left outer join, rather than the default
37 inner join. If more than two files are provided this
38 will be executed as a sequence of left outer joins,
39 starting at the left.
40 --right Perform a right outer join, rather than the default
41 inner join. If more than two files are provided this
42 will be executed as a sequence of right outer joins,
43 starting at the right.
44 -y SNIFF_LIMIT, --snifflimit SNIFF_LIMIT
45 Limit CSV dialect sniffing to the specified number of
46 bytes. Specify "0" to disable sniffing entirely, or
47 "-1" to sniff the entire file.
48 -I, --no-inference Disable type inference (and --locale, --date-format,
49 --datetime-format, --no-leading-zeroes) when parsing
50 the input.
51
52 Note that the join operation requires reading all files into memory. Don't try
53 this on very large files.
54
55 See also: :doc:`../common_arguments`.
56
57 Examples
58 ========
59
60 .. code-block:: bash
61
62 csvjoin -c 1 examples/join_a.csv examples/join_b.csv
63
64 Add two empty columns to the right of a CSV:
65
66 .. code-block:: bash
67
68 echo "," | csvjoin examples/dummy.csv -
69
70 Add a single column to the right of a CSV:
71
72 .. code-block:: bash
73
74 echo "new-column" | csvjoin examples/dummy.csv -