Skip to content
Advertisement

Write javascript array elements to file

I am trying to have a node js script write some coordinates to a csv file for use in a Newman CLI script. I have the following:

JavaScript

I have been looking through and trying numerous different tutorials/code snippets regarding writing the array elements from arrLatLon to an output file on my local machine, but none have been successful. The current code outputs the lat,lon correctly, console.log(arrLatLon) outputs:

JavaScript

any help would be greatly appreciated. Thanks.

Advertisement

Answer

With nodejs you can easily write files using the fs module

JavaScript

in your case you can simply do something like

JavaScript

Let me forward you to this question for more information Writing files in Node.js

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement