Get Data from Text File to Multidimensional Array Javascript -
i have little bit of issue javascript function needs read info textfile (something js limited with) , process tha textfile info multidimensional array (another thing js doesn't nativelly suport).
with in mind, have text file in format:
1, name, data, serial 2, name, data, serial 3, name, data, serial
and on.
so, objective same info , set it, that, array.
i suppose that, i've been reading, need array of array, segmenting first 1 lines [/n] , sec 1 commas [,]. however, given "by-default" limitations, i'm confused @ point. suppose need jquery, however.
i tried this:
var fs = require('fs'); var array = fs.readfilesync('file.txt').tostring().split("\n"); for(i in array) { var array = fs.readfilesync('file.txt').tostring().split(","); for(f in array) { } }
with little success, because don't know how store it, objective beingness multidimensional array replicates format of text file, latter used search index or instance next user input results.
i appreciate help.
at first glance seems trying read in csv file. if indeed case recommend node-csv:
http://www.adaltas.com/projects/node-csv/
https://github.com/wdavidw/node-csv
javascript arrays node.js multidimensional-array text-files
No comments:
Post a Comment