Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

objects-to-csv

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

objects-to-csv

Converts an array of objects into a CSV file. Saves CSV to disk or returns as string.

  • 1.3.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
121K
decreased by-6%
Maintainers
1
Weekly downloads
 
Created

What is objects-to-csv?

The objects-to-csv npm package is a simple and efficient tool for converting JavaScript objects into CSV (Comma-Separated Values) format. It is particularly useful for exporting data to CSV files, which can then be used for data analysis, reporting, or sharing with other systems.

What are objects-to-csv's main functionalities?

Convert Objects to CSV String

This feature allows you to convert an array of JavaScript objects into a CSV string. The code sample demonstrates how to create a CSV string from an array of objects.

const ObjectsToCsv = require('objects-to-csv');

const data = [
  { name: 'John', age: 30, city: 'New York' },
  { name: 'Jane', age: 25, city: 'San Francisco' }
];

const csv = new ObjectsToCsv(data);
const csvString = await csv.toString();
console.log(csvString);

Save CSV to File

This feature allows you to save the CSV string to a file on disk. The code sample demonstrates how to write the CSV data to a file named 'data.csv'.

const ObjectsToCsv = require('objects-to-csv');

const data = [
  { name: 'John', age: 30, city: 'New York' },
  { name: 'Jane', age: 25, city: 'San Francisco' }
];

const csv = new ObjectsToCsv(data);
await csv.toDisk('./data.csv');
console.log('CSV file saved.');

Append Data to Existing CSV File

This feature allows you to append new data to an existing CSV file. The code sample demonstrates how to append a new object to the existing 'data.csv' file.

const ObjectsToCsv = require('objects-to-csv');

const newData = [
  { name: 'Alice', age: 28, city: 'Los Angeles' }
];

const csv = new ObjectsToCsv(newData);
await csv.toDisk('./data.csv', { append: true });
console.log('Data appended to CSV file.');

Other packages similar to objects-to-csv

Keywords

FAQs

Package last updated on 04 Jan 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