Turn your CSV files to queryable objects.
Node-csv-query loads the entire CSV file in memory, thanks to csv-parse, then plug lodash manipulation functions on the loaded dataset. This can be handy for demo project as your code will have a databsae ready syntax while your dataset is easily editable even for non developer.
⚠️Warning⚠️: this library is not meant for performance!
How to use
dataset.csv
id,firstName,lastName,amountOfBooks1,Olivier,Kaisin,102,Emile-Victor,Portenart,23,Alex,Mapolice,424,Alex,Gaspy,2
Connect to your csv database
'use strict'; var csvdb = ;var databaseConnection = null; ;
firstName=Olivier
How to find the row with databaseConnection
firstName=Alex
How to find the rows with databaseConnection
firstName
How to find the rows with having an 'i' in their This lib use lodash for querying the dataset. All query format are listed here. node-csv-query will just pass the query param to lodash as the predicate argument.
databaseConnection
How to deal with different dataset format
This lib is based on csv-parse for parsing csv files. All available options for parsing the CSV are listed here. node-csv-query will just pass these option to csv-parse with the exception of the columns option that will be overrided to true for internal mechanism to works.
dataset_custom.csv
# this dataset has comment & semi colon separator & space before separatorid;firstName ;lastName ;amountOfBooks1 ;Olivier ;Kaisin ;102 ;Emile-Victor;Portenart;23 ;Alex ;Mapolice ;424 ;Alex ;Gaspy ;2
'use strict'; var csvdb = ; ;
Compatibility
This lib has been packaged for Node >= v8.9 .
License
MIT