1.0.23 • Published 1 month ago

datakit v1.0.23

Weekly downloads
19
License
MIT
Repository
github
Last release
1 month ago

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.

1.0.23

1 month ago

1.0.22

1 month ago

1.0.21

1 month ago

1.0.20

1 month ago

1.0.19

7 months ago

1.0.18

11 months ago

1.0.17

11 months ago

1.0.16

12 months ago

1.0.11

12 months ago

1.0.15

12 months ago

1.0.14

12 months ago

1.0.13

12 months ago

1.0.12

12 months ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.10

1 year ago

1.0.4

3 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.8.0

12 years ago