New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dbl-works/csv-unique-values

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dbl-works/csv-unique-values

Get unique values from a CSV file

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

csv-unique-values

A script to get unique values from columns in any CSV file.

Our use case is to run this script to populate in-app dropdowns with all possible values, but there's plenty more you can do with it, for example if you want to remove duplicates from a list of e-mails or phone numbers, …

Usage

Pull in this repository locally, then run

Usage: node index.js [options]

Options:
  -v, --version                output the version number
  -i, --input <file>           input CSV file
  -d, --delimiter <delimiter>  delimiter used in the CSV (default: ",")
  -c, --columns <columns>      columns to extract, comma-separated
                               you can get unique values per unique values from another column by
                               chaining them together using `::`
                               (default: all columns)
  -o, --output <directory>     output destination, will create a file per column
  --no-sort                    don't sort unique values
  -h, --help                   display help for command

If we publish this to NPM, it'd be

npx @dbl-works/csv-unique-values [options]

Example

For an example input file team.csv

Name, Country, Region
Joe, US, NA
Joelle, US, NA
John, CA, NA
Johan, DE, EU
Johanna, DE, EU

and running

npx @dbl-works/csv-unique-values --input team.csv --keys country --output ~/Desktop/team-country

will generate country.json with contents

[
  "CA",
  "DE",
  "US"
]

To get all countries per region you can run:

npx @dbl-works/csv-unique-values --input team.csv --keys region::country --output ~/Desktop/team-country

and you will get:

{
  "NA": [
    "CA",
    "US",
  ],
  "EU": [
    "DE"
  ]
}

FAQs

Package last updated on 27 Apr 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc