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.pitchcow,mammal,moo-moo,lowswiss cow,mammal,moo-moo,lowcrow,bird,kaa-kaa,highdonkey,mammal,yee-haw,low
Search a single column
const lookupCSV = ; // Create a lookup table using lookup column name to use from the csv dataconst lookupTable = // Get rows matching lookup valuematchingRows = lookupTable// {// animal: 'cow',// type: 'mammal',// sound: {// type: 'moo-moo',// pitch: 'low'// }// }