Read file and create loop

0

I have a txt file with multiple column names:

Nome 01
Nome 02
Nome 03...

In .js files I need to create a loop so that each name is read and loaded into a variable so that the calculations are done and saved to a file with the individual name.

The part of the calculations is already done, but I can not read the txt file and create the loop.

What I have right now is:

var fs = require("fs"),
d3 = require("d3"),
mkdirp = require("mkdirp");

fs.readFile('file.txt', 'utf-8', function(err, data){
    var linhas = data.split(/\r?\n/);
    linhas.forEach(function(linha){

var flightId = "linha", 


      mkdirp("data", function(err) {
        if (err) console.error(err);
        else {
          fs.writeFile("data/" + flightId + ".tsv", csvFormated);
          fs.writeFile("data/data.geojson", JSON.stringify(geojson));
        }
      });
    } else {
      console.log("Flight data not found");
    }
  });
    
asked by anonymous 14.05.2018 / 16:11

0 answers