ryu1kn / csv-writer

Convert objects/arrays into a CSV string or write them into a CSV file
https://www.npmjs.com/package/csv-writer
MIT License
246 stars 39 forks source link

example doesnt' work #49

Closed ralyodio closed 4 years ago

ralyodio commented 4 years ago
function writeCsv() {
  const csvWriter = createCsvWriter({
    path: argv.file.replace('.json', '.csv'),
    header: [
      { id: "title", title: "TITLE" },
      { id: "phone", title: "PHONE" },
      { id: "link", title: "LINK" },
    ],
  });

  csvWriter.writeRecords(all) // returns a promise
    .then(() => {
      console.log("...Done");
    });
}

I just get an empty csv file

ryu1kn commented 4 years ago

Hi @chovy the snippet looks fine to me assuming all is a list of records (objects or arrays). Can you provide me a complete code snippet that reproduces the behaviour you’re seeing so that i can have a closer look at it?

ralyodio commented 4 years ago

closing. i didn't await.