Socket
Socket
Sign inDemoInstall

csv-append

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv-append

Append data to a big csv file.


Version published
Maintainers
1
Created
Source

csv-append

Low memory overhead, append-only csv writer.

Abstraction over csv-write-stream.

Install

  yarn add csv-append

Usage

Create a new file

import csvAppend from "csv-append";
const RELATIVE_PATH_TO_CSV = `./data/output.csv`;
const { append, end } = csvAppend(RELATIVE_PATH_TO_CSV);

append([{ a: 1, b: 2 }, { a: 2, b: 3 }]);
// Or
append({ a: 1, b: 2 });
append({ a: 2, b: 3 });

await end();
console.log(fs.readFileSync(RELATIVE_PATH_TO_CSV, { encoding: "utf8" }));
/* 
a,b
1,2
b,3
*/

Append to file

import csvAppend from "csv-append";
const RELATIVE_PATH_TO_CSV = `./data/output.csv`;
const { append, end } = csvAppend(RELATIVE_PATH_TO_CSV, true);

// append([{ a: 1, b: 2 }, { a: 2, b: 3 }]);
// Or
append({ a: 1, b: 2 });
append({ a: 2, b: 3 });

await end();
console.log(fs.readFileSync(RELATIVE_PATH_TO_CSV, { encoding: "utf8" }));
/* 
a,b
1,2
b,3
*/

API

csvAppend

Input :
  • path: string (required)
  • appendToFile: boolean (optional, default false)
Output :
{
  append: append (👇),
  end: end (👇)
}

append

append adds an object or an array of objects to the end of the csv file.

Input :
  • args: Array<any> | Array<Array<any>>
Output :

void

end

end returns a promise that resolves when the csv has been written to the fs.

Input :

None

Output :

Promise<void>

FAQs

Package last updated on 11 Oct 2018

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