Skip to main content

kvenn

CLI Tool for doing set-operations on lines of input. Each line is treated as an item in a set. Each input is treated as a set.

Usage

usage: kvenn [-h] [-n] [-s] [-x] [--force-string-keys] [-f FORMAT]
             [-o {+,-,x,d,union,difference,intersection,unique}]
             sets [sets ...]

positional arguments:
  sets                  Each file is a set and each line in the file is a
                        member of the set

optional arguments:
  -h, --help            show this help message and exit
  -n, --non-empty       non-empty values only
  -s, --strip           strip surrounding whitespace
  -x, --filter          strip and filter to non-empty
  --force-string-keys   JSON set keys should be forced to a string type
  -f, --format FORMAT   Output handler (csv,json/ndjson,text)
                        default=whatever your first input was
  -o {+,-,x,d,union,difference,intersection,unique,stats}, --operation {+,-,x,d,union,difference,intersection,unique,stats}
                        Operation to perform on the sets [-] Subtract sets
                        1...N from set 0 [+] Get the union of sets 0...N [x]
                        Get the intersection of sets 0...N [d] Symmetric
                        difference (disjunctive union). Elements from all sets
                        which are not in any others. [stats] Print a summary
                        of all operations and per-source breakdowns.

Input Formats

kvenn supports three input formats. The format is detected from the file extension.

Plain text

Each line is treated as a set member. No special syntax needed.

kvenn file1.txt file2.txt

CSV

Use :: to specify which column(s) to use as the set key:

kvenn data1.csv::color data2.csv::color

Multiple key columns are supported:

kvenn data1.csv::id,color data2.csv::id,color

NDJSON (newline-delimited JSON)

Works the same as CSV — use :: to specify the key field(s):

kvenn data1.json::id data2.json::id

Nested keys use dot notation:

kvenn data1.json::meta.id data2.json::meta.id

Files with .json or .ndjson extensions are both supported.

Output format

By default the output format matches the first input file. Override with -f:

kvenn data1.csv::color data2.csv::color -f json

Examples

Unique values in a file

kvenn <input>

Unique values in two or more files (Also --operation union)

kvenn <input1> <input2> <inputN>

Values found in both files

kvenn <input1> <input2> --operation intersection

Values found in only one file

kvenn <input1> <input2> <inputN> --operation unique

Subtract values in B (and C, D.. etc) from A. (Unique values from A)

kvenn <inputA> <inputB> [<inputC>] --operation difference

Get a summary of all set operations at once

kvenn data_1.txt data_2.txt --operation stats

All (2 sources, 17 total unique items):
  Union:                       17    (e.g. Purple)
  Intersection:                 3    (e.g. Purple)
  Difference (A - B):           7    (e.g. Teal)
  Symmetric difference:        14    (e.g. Teal)

Source 1 - data_1.txt:
  Total:        10
  Unique:        7    (e.g. Teal)

Source 2 - data_2.txt:
  Total:        10
  Unique:        7    (e.g. Pink)

Development

make install-dev
make test

Metadata

Release files for kvenn 2.1.0

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

Source distribution (sdist)

Source distribution for kvenn 2.1.0
File Size Uploaded Provenance
kvenn-2.1.0.tar.gz 19.7 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 26.9 kB

Release files / kvenn-2.1.0.tar.gz

Download URL kvenn-2.1.0.tar.gz
Size 19.7 kB
Tags Source
SHA-256 checksum
How to use checksums
88a5bb97a16bf67177637fbfeff4f670989dfbc9464dfbe6a72d13b6bc5c9c08
BLAKE2b-256 checksum
How to use checksums
ec4259045c913cf89da0ae0819236917ce4b384dfb15db93fad5d30fae12ac88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / kvenn-2.1.0-py3-none-any.whl

Download URL kvenn-2.1.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c302884742b5550f8195c03e2055c438c5448fa29ad7dc44ec0ef4e88710a3ca
BLAKE2b-256 checksum
How to use checksums
b35b81e992754fd83061b28f6380367950f8d1d2d21aabf8960e32d04b419e3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for kvenn 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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