Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

csv-parse-htt

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

csv-parse-htt

This is a simple package that provides a CSV parsing and validation utility. It uses the Papaparse library for parsing CSV data and supports optional validation using the Yup schema validation library.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

CSV Parse Component

This is a simple package that provides a CSV parsing and validation utility. It uses the Papaparse library for parsing CSV data and supports optional validation using the Yup schema validation library.

Installation

To install this package, use npm:

npm install csv-parse-component

Usage

Here's how you can use the parseCSV function provided by this package:

const CsvParseComponent = require("csv-parse-htt");
const yup = require("yup");

const csvString = "Name,Age\nJohn,25\nJane,30\nAlice,28\nMartin,25\nRob,32";
const config = {
  header: true,
};

const userSchema = {
  Name: yup.string().required(),
  Age: yup.number().required().positive().integer(),
};

const { valid, validData, invalidData } = CsvParseComponent.parseCSV(
  csvString,
  config,
  userSchema
);
if (!valid) {

  console.log("Data is valid:", validData);

  console.error("Validation errors:", invalidData);

} else {

  console.log("All Data is valid:", validData);
}

API

parseCSV(csvString, config, userSchema)

Parses a CSV string and performs optional validation using a provided schema.

ParameterDescription
csvStringThe CSV string to parse.
configAn object with parsing configuration options for Papaparse. For example, { header: true } if your CSV data includes a header row.
userSchemaAn optional Yup schema for validation.

Returns an object with the following properties:

PropertyDescription
validA boolean indicating if the CSV data passed validation.
validDataAn array of valid data rows.
invalidDataAn array of objects containing information about invalid data rows, including the row index, row data, and validation errors.

Keywords

FAQs

Package last updated on 09 Aug 2023

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