Skip to main content

csvcat - Concatenate comma separated value files.

csvcat reads one or more comma separated value text file (a CSV file) and outputs some or all of the data in the same format. It includes options for limiting and reordering the columns in the output, as well as skipping repeated headers.

Installation

The simplest way to install is using pip:

$ pip install csvcat

If you have already downloaded the source and unpacked it, you can also install by running:

$ sudo python setup.py install

Usage

Run csvcat --help for a complete description of all options, including examples of how to use the program in various modes.

Examples

The inputs to csvcat are any number of CSV files, and the output is CSV data printed to standard output. The examples listed below assume two simple CSV files.

$ cat testdata1.csv
"Title 1","Title 2","Title 3"
1,"a",08/18/07
2,"b",08/19/07
3,"c",08/20/07

$ cat testdata2.csv
Title 1,Title 2,Title 3
40,D,08/21/07
50,E,08/22/07
60,F,08/23/07

When given no options, csvcat simply prints the contents of an input file to standard output.

$ csvcat testdata1.csv
Title 1,Title 2,Title 3
1,a,08/18/07
2,b,08/19/07
 3,c,08/20/07

To select which columns should be included in the output, use the --columns option. Columns are identified by their number, beginning with 0. Column numbers can be listed in any order, so it is possible to reorder the columns of the input data, if needed.

$ csvcat --columns 2,0 testdata1.csv
Title 3,Title 1
08/18/07,1
08/19/07,2
08/20/07,3

Different output formats can be selected by using the --dialect option. There are only two dialects available by default, but the csv module API supports registering additional dialects.

$ csvcat --dialect excel-tab testdata1.csv
Title 1 Title 2 Title 3
1       a       08/18/07
2       b       08/19/07
3       c       08/20/07

To merge multiple files, only including a single set of headers, use the --skip-headers option:

$ csvcat --skip-headers --columns 2,0 testdata1.csv testdata2.csv
Title 3,Title 1
08/18/07,1
08/19/07,2
08/20/07,3
08/21/07,40
08/22/07,50
08/23/07,60

Metadata

Release files for csvcat 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csvcat 2.0.2
File Size Uploaded
csvcat-2.0.2.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for csvcat 2.0.2
File Interpreter ABI Platform
csvcat-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / csvcat-2.0.2.tar.gz

Download URL csvcat-2.0.2.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e61a70e470d5480ca55cda0da46354b3b45d5a72f4e82c6c075312d0a8d2785b
BLAKE2b-256 checksum
How to use checksums
151142c268fcc69999e6b4824dddbb6c27a2cd5ae098a56a88605ce6e4126aba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / csvcat-2.0.2-py3-none-any.whl

Download URL csvcat-2.0.2-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6d9ba1adb8410dbcd4fbc9b2d608e58d33e97d3dc59cf9eab8d45ad6c5d6bef
BLAKE2b-256 checksum
How to use checksums
5d25f01d33c9f3be4c9d3e5c9ed03fb97cc3a5c74ca390b77ac983982135f854
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

1 release file

2.0.0

1 release file

1.1

1 release file

1.0

0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page