Skip to content

Instantly share code, notes, and snippets.

@rafaelhdr
Created May 22, 2015 13:22
Show Gist options
  • Save rafaelhdr/bbb1e56569c13f2deec9 to your computer and use it in GitHub Desktop.
Save rafaelhdr/bbb1e56569c13f2deec9 to your computer and use it in GitHub Desktop.
Read file and convert to Array X Array
var fs = require('fs');
var outputArray = [];
var content = fs.readFileSync('map.txt').toString('utf8');
var lines = content.split('\n');
lines.forEach(function(line){
var cells = line.split(' ');
var newArray = [];
cells.forEach(function(cell){
newArray.push(parseInt(cell));
});
outputArray.push(newArray);
});
console.log(outputArray);
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment