Socket
Book a DemoInstallSign in
Socket

lookup-csv

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lookup-csv

Quickly search and lookup rows from a csv file

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

lookup-csv

A node module to quickly search and lookup rows from a CSV file using a JSON API.

An input CSV file is converted to an array of JSON objects using treeize. This is used to build a lookup table by specifying a coumn name as an index using hasharray.

Installation

Install module npm i lookup-csv

Simple usage

For a given data.csv, ensure the first row contains the column names. Adding a . delimiter in the column names will nest the property in the JSON result

animal,type,sound.type,sound.pitch
cow,mammal,moo-moo,low
swiss cow,mammal,moo-moo,low
crow,bird,kaa-kaa,high
donkey,mammal,yee-haw,low

Search a single column

const lookupCSV = require('lookup-csv');

// Create a lookup table using lookup column name to use from the csv data
const lookupTable = lookupCSV('./path/to/data.csv', 'animal')

// Get rows matching lookup value
matchingRows = lookupTable.get('cow')
// {
//     animal: 'cow',
//     type: 'mammal',
//     sound: {
//          type: 'moo-moo',
//          pitch: 'low'
//     }
// }

Keywords

csv

FAQs

Package last updated on 13 Feb 2020

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