New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

datakit

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datakit

Simple JavaScript/TypeScript library for reading and writing CSV and JSON data files.

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
48
increased by45.45%
Maintainers
1
Weekly downloads
 
Created
Source

datakit

Simple toolkit for reading and writing data CSV and JSON files in JavaScript and TypeScript under Node.js.

Click here for API docs.

Install

Install using npm:

npm install --save datakit

Read and write CSV files (JavaScript)

Ready to see some code?

Here's an example of transforming a CSV file using JavaScript:

const { readCsv, writeCsv } = require("datakit");

function transform(record) {
    // Your function to transform a data record.
}

async function main() {
    const data = await readCsv("./some/file.csv");
    const transformed = data.map(transform);
    await writeCsv("./an/output/file.csv", transformed);
}

main()
    .then(() => console.log("Done"))
    .catch(err => {
        console.error("Something went wrong.");
        console.error(err && err.stack || err);
    });

Read and write JSON files (TypeScript)

Here's a similar code example using TypeScript.

This time we are reading and writing JSON files:

import { readJson, writeJson } from "datakit";

function transform(record: InputT): OutputT {
    // Your function to transform a data record.
}

async function main(): Promise<void> {
    const data = await readJson("./some/file.json");
    const transformed = data.map(transform);
    await writeJson("./an/output/file.json", transformed);
}

main()
    .then(() => console.log("Done"))
    .catch(err => {
        console.error("Something went wrong.");
        console.error(err && err.stack || err);
    });

Need to do more?

Consider using Data-Forge for data transformation, analysis and visualization in JavaScript and TypeScript.

Resources

  • API docs

Keywords

FAQs

Package last updated on 14 Feb 2020

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