Created
October 25, 2013 12:31
-
-
Save edinella/7153960 to your computer and use it in GitHub Desktop.
JS to CSV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dados = [ | |
['Nome', 'Sobrenome', 'Profissão'], | |
['Paula', 'Tejando', 'Adivinha' ], | |
['Cuca', 'Beludo', 'Padeiro' ], | |
['Thomas', 'Turbano', 'Popeye' ] | |
]; | |
var csv = dados.map(function(linha){ | |
return linha.map(function(celula){ | |
return '"'+(celula.replace(/\"/g, '\"').replace(/\r/g, '\\r'))+'"'; | |
}).join(';'); | |
}).join('\n'); | |
console.log(csv); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment