You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP →
Socket
Book a DemoInstallSign in
Socket

@farmfe/plugin-dsv

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@farmfe/plugin-dsv

šŸ£ A Farm plugin which converts `.csv` and `.tsv` files into JavaScript modules.

0.0.8
latest
Source
npm
Version published
Weekly downloads
409
11.75%
Maintainers
0
Weekly downloads
Ā 
Created
Source

@farmfe/plugin-dsv

šŸ£ A Farm plugin which converts .csv and .tsv files into JavaScript modules.

Requirements

This plugin requires an LTS Node version (v18.0.0+) and Farm v1.0.0+.

Installation

npm i @farmfe/plugin-dsv

Usage

Create a farm.config.js configuration file and import the plugin:

import { defineConfig } from '@farmfe/core';
import dsv from '@farmfe/plugin-dsv';

export default defineConfig({
  plugins: [
    [
      dsv()
    ]
  ],
});

Practical Example

Suppose that you have a CSV (or TSV!) file which contains some information on delicious fruits:

type,count
apples,7
pears,4
bananas,5

And suppose you'd like to import that CSV as an Array within some part of your code. After adding the plugin (as shown above), you may import (or require) the CSV file directly. The import will provide an Array of Objects representing rows from the CSV file:

import fruit from './fruit.csv';

console.log(fruit);
// [
//   { type: 'apples', count: '7' },
//   { type: 'pears', count: '4' },
//   { type: 'bananas', count: '5' }
// ]

Keywords

rust

FAQs

Package last updated on 25 Dec 2024

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