# unique-columns

> Finds which columns are unique in tabular data

Latest version **1.0.2** (published 2015-11-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install unique-columns
pnpm add unique-columns
yarn add unique-columns
bun add unique-columns
```

Provides the command `unique-columns`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2015-11-30 |
| First published | 2015-11-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Karissa McKelvey |
| Maintainers | karissa |
| Keywords | data, table, tables, duplicate, duplicates, unique columns, unique, columns, cols, tabular, dataset |

## Links

- npm: https://www.npmjs.com/package/unique-columns
- Repository: https://github.com/karissa/unique-columns
- Homepage: https://github.com/karissa/unique-columns#readme
- Issues: https://github.com/karissa/unique-columns/issues
- npm.io page: https://npm.io/package/unique-columns

## Dependencies (6)

- [pump](https://npm.io/package/pump.md) ^1.0.0
- [tape](https://npm.io/package/tape.md) ^4.2.2
- [ndjson](https://npm.io/package/ndjson.md) ^1.4.1
- [minimist](https://npm.io/package/minimist.md) ^1.1.2
- [through2](https://npm.io/package/through2.md) ^2.0.0
- [parse-input-stream](https://npm.io/package/parse-input-stream.md) ^1.0.1

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2015-11-30
- 1.0.1 — 2015-11-30

## README

unique-columns
----------------

 [![Travis](http://img.shields.io/travis/karissa/unique-columns.svg?style=flat)](https://travis-ci.org/karissa/unique-columns)

Get the unique columns in a dataset. Useful if you need to quickly see what columns in a table are unique. `unique-columns` is **streaming**, too, which means that running this on a very large dataset won't kill your RAM because the table is only loaded into memory one row at a time. Cool!

```
npm install -g unique-columns
```

## Example

Imagine, your worst nightmare. You are given a dataset that contains two different columns that could possibly be the unique identifier. But you aren't sure.

In this case, two of these columns could be unique, 'username' and 'id', but how will you know for sure?

Run `unique-columns people.csv`, of course!

people.csv
```
name, age, id, username, description
angela, 29, 1, ange___1, "just a person here"
bob, 34, 2, iambob, "innovator in technology"
bob, 55, 3, bob2234, "Dad, Father, Do-gooder"
samantha, 34, 5, sam_does, "making a living, being a person"
laura, 34, 5, hanna_boss, "continuing to be a badass"
```

```
$ unique-columns people.csv
uniques:
   username
   description

duplicates:
   age: 3
   id: 2
```

We see that `id` and `age` contain duplicate values, while `username` and `description` are unique.

## Usage
unique-columns will try to guess the format, but you can supply it if you really want to.

```
$ unique-columns <tabular-file> [--format=csv/ndjson]

OR

$ cat <tabular-file> | unique-columns -
```

## Options

`--format/-f` : the format in which to expect data. tries to guess if not supplied.
`--json`: output machine-readable format in json

## JavaScript usage

An incoming jsonStream gets turned into a dictionary of the duplicates:

```
  {
    "name": 2,
    "age": 3,
    "id": 0,
    "description": 0,
    "username": 0,
  }
```

Use it with any parsed json input stream:

```js
var parseInputStream = require('parse-input-stream')
var dupes = require('unique-columns')

var args = {"format": "csv"}
var jsonStream = process.stdin.pipe(parseInputStream(args))

dupes(jsonStream, function done (err, duplicates) {
  console.log(duplicates)
})

```

## TODO

1. Give a limit for the number of rows to peek on before stopping
3. Tests
4. Give percentage of duplicates along with absolute values

---
_Source: https://npm.io/package/unique-columns · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
