GithubHelp home page GithubHelp logo

lukejkw / datakit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ashleydavis/datakit

0.0 0.0 0.0 725 KB

Simple JavaScript toolkit for data transform across JSON, CSV and YAML.

License: MIT License

JavaScript 3.37% TypeScript 96.63% Batchfile 0.01%

datakit's Introduction

datakit

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

API docs

CLI docs

Support my work

Install

Install using npm:

npm install --save datakit

Install globally for the command line tools:

npm install -g 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);
    });

You can also read and write YAML files using similar functions.

Need to do more?

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

Resources

Support the developer

Click here to support the developer.

datakit's People

Contributors

ashleydavis avatar lukejkw avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.