javascript - running error with console.log(util.format -


first have say, i'm new node.js.

one of mate helped me piece of code below.

i've installed required packages search-google-geocode , csv-parser , fs , util , async through npm.

yet, when i'm running it.

i've got error

console.log(util.format("  area %s", preciseloc.area);                 ^^^^^^^ syntaxerror: unexpected identifier     @ module._compile (module.js:439:25)     @ object.module._extensions..js (module.js:474:10)     @ module.load (module.js:356:32)     @ function.module._load (module.js:312:12)     @ function.module.runmain (module.js:497:10)     @ startup (node.js:119:16)     @ node.js:906:3 

i thought first due missing semi-colon not case.

does sound familiar? if yes, have ideas on how fix issue?

the piece of code

var geocoder = require('search-google-geocode'); var csv = require('csv-parser'); var fs = require('fs'); var util = require('util'); var async = require('async');  var options = {     language: 'fr' };  var locs = [];  var csvreader = fs.createreadstream('locs2.csv').pipe(csv());  var georesult = function(err, result) { }  csvreader.on('data', function(data) {     locs.push(data); });  var rowcount = 1; csvreader.on('end', function() {     console.log(locs.length + " rows read csv");     async.eachseries(locs, function(loc, cb) {         console.log("\nlooking row " + rowcount + ": " + loc.lat + "," + loc.lon);         rowcount++;         geocoder.reversegeocode(loc.lat, loc.lon, function(err, result) {             if (err) {                 console.log(err);             } else {                 var preciseloc = result[0];                 console.log(util.format("reverse geocode: %s, %s", preciseloc.latitude, preciseloc.longitude)                 console.log(util.format("  area %s", preciseloc.area));                 console.log(util.format("  zip %s", preciseloc.zipcode));             }              cb();         } , options);     },      function(err) {         return null;     }); }); 

it looks me line:

console.log(util.format("reverse geocode: %s, %s", preciseloc.latitude, preciseloc.longitude) 

is missing closing bracket , should changed to:

console.log(util.format("reverse geocode: %s, %s", preciseloc.latitude, preciseloc.longitude)); 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -