Neighborly Package Megalodon

    daki
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.3 • Public • Published

    daki

    Daki has been republished as datakit and this version of the module is no longer maintained.

    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 daki
    

    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("daki");
    
    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");
    }
    
    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 "daki";
    
    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");
    }
    
    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

    Install

    npm i daki

    DownloadsWeekly Downloads

    11

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    46.6 kB

    Total Files

    11

    Last publish

    Collaborators

    • ashleydavis