Skip to content

All in one npm package that allows a developer to convert any csv file to or from an array of objects.

Notifications You must be signed in to change notification settings

davidcolatti/csv-to-and-from-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

csv-to-and-from-array

All in one npm package that allows a developer to convert any csv file to or from an array of objects.

Install using yarn or npm:

yarn add csv-to-and-from-array
npm install csv-to-and-from-array
const { csvFileToArray, arrayToCsvFile } = require("csv-to-and-from-array");

// An asynchronous function that takes one object parameter:
// filePath: a string, the path of the current csv file that will be converted
// callback: function that is called once the conversion is completed, optional
const array = await csvFileToArray({
  filePath: "./data.csv",
  callback: () => console.log("File conversion completed"),
});

// A synchronous function that takes one object parameter:
// data: array of objects
// filePath: a string, the path of the output file after conversion, by default it is 'output.csv'
// callback: function that is called once the conversion is completed, optional
arrayToCsvFile({
  data: [{ id: 1, name: "John Smith" }],
  filePath: "../folder/newOutput.csv",
  callback: () => console.log("Array is now a csv file"),
});

License

MIT

About

All in one npm package that allows a developer to convert any csv file to or from an array of objects.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published