Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Query on CSV allows you to perform queries on CSV.
This package is suitable for you if you need to perform some queries on:
npm i csvqry
or
yarn add csvqry
Just import/require the package before start using it.
As a Node.js Package
const csvq = require("csvqry");
As a ES6 Module
import csvq from "csvqry";
(async () => {
try {
const qb = await csvq.from("example.csv");
let result = qb.get();
console.log(result);
} catch (error) {
console.error("Error initializing csvq:", error);
}
})();
You can perform queries on your csv:
let qb = await csvq.from("example.csv");
let result = qb
.select("id", "name")
//.select(['id', 'name'])
.where("id", 2)
//.where('id', '>' ,2)
.orWhere("id", 3)
//.orWhere('id', '>=', 3)
.whereDate("dob", "2010-10-10")
//.whereDate('dob', '>=','2010-10-10')
.whereLike("name", "ruhul")
//.whereLike('name', 'ruhul', 'start')
//.whereLike('name', 'ruhul', 'end')
.whereIn("age", [22, 23, 25, 26])
.whereNotIn("age", [11, 12, 13])
.orderBy("id")
//.orderBy('id', 'desc')
//.orderBy('id', 'asc')
//.latest('id') // Default Id
//.oldest('id') // Default Id
.get();
let qb = await csvq.from("example.csv");
// To Get All Result
const result = qb.all();
// To Get All Sorted Result
const result = qb.orderBy("id", "desc").all();
// To Get Specific Row
const result = qb.where("id", 1).row();
// To Get First Result
const result = qb.where("id", 1).first();
// To Get Last Result
const result = qb.where("id", 1).last();
// To Get nth row
const result = qb.getNth(2); // [0-n]
// Check Is row exist
const result = qb.where("id", 1).hasData(); // boolean
const result = qb.where("id", 1).exist(); // boolean
// To Get All Sorted Result
const result = qb.orderBy("id", "desc").all();
=
(default operator, can be omitted)>
<
<=
>=
!=
ASC
DESC
(default operator, can be omitted)asc
desc
You can add criteria and specify limit and offset for your query results:
let qb = await csvq.from("example.csv");
const result = qb
.select("*")
.orderBy("id")
.limit(10)
//.limit(10, 2)
.get();
You can add criteria and specify limit and offset for your query results:
let qb = await csvq.from("example.csv");
// To Get Count
const result = qb.count();
// To Get Sum
const result = qb.sum("age");
// To Get Average
const result = qb.avg("age");
// To Get row with minimum column value
const result = qb.min("age");
// To Get row with maximum column value
const result = qb.max("age");
If you found an issue or had an idea please refer to this section.
FAQs
Make data retrieval query on CSV like laravel `Query Builder`
The npm package csvqry receives a total of 0 weekly downloads. As such, csvqry popularity was classified as not popular.
We found that csvqry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.