I'm trying to read CSV with Javascript, but I'm getting an error.
Here is my code:
fs.readFile('./data/AMZN.csv', async (err,data)=>{
if(err){
console.log(err)
return
}
console.log(data.replace("$",""));
})
Here is the example of my CSV data:
Date, Close/Last, Volume, Open, High, Low
09/11/2020, $3116.22, 5093982, $3208.69, $3217.3409, $3083.98
09/10/2020, $3175.11, 5330741, $3307.219, $3349.89, $3170.55
09/09/2020, $3268.61, 5188675, $3202.99, $3303.175, $3185
And here is the error that I get:
SyntaxError: Unexpected number
at wrapSafe (internal/modules/cjs/loader.js:1072:16)
at Module._compile (internal/modules/cjs/loader.js:1122:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\jackl\Desktop\Projects\scraper_cheerio\scraper.js:5:14)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
I've figured out that Javascript perceives $3116 as a string and the following .22 as a property of that string object, which can not be a number and therefore throws "Unexpected number".
But how do I fix it? I've been trying to deal with it for 2 days, but no luck so far.
The problem was in this line:
const AMZN = require("./data/AMZN.csv");
The code in the question works fine.
Related
During the install of this github project I get this error:
Error: Invalid JSON RPC response: undefined
at Object.InvalidResponse (C:\Users\backu\blockchain\Blockchain4LinkedData-master\Dapp\node_modules\web3\lib\web3\errors.js:35:16)
at HttpProvider.send (C:\Users\backu\blockchain\Blockchain4LinkedData-master\Dapp\node_modules\web3\lib\web3\httpprovider.js:91:22)
at RequestManager.send (C:\Users\backu\blockchain\Blockchain4LinkedData-master\Dapp\node_modules\web3\lib\web3\requestmanager.js:58:32)
at Eth.send [as getBlock] (C:\Users\backu\blockchain\Blockchain4LinkedData-master\Dapp\node_modules\web3\lib\web3\method.js:145:58)
at Object. (C:\Users\backu\blockchain\Blockchain4LinkedData-master\Dapp\app\routes.js:31:22)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
Could someone help me with this?
Most likely, when the geth was launched, one of the modules whose methods were used by Dapp was not enabled in the settings of the RPC API. Look at the value of the --rpcapi key from the startup line.
i am trying execute test with jest in CRA and i keep getting this weird error.
C:\Users\mfonpah\Documents\projects\nexus-web-client\web-
client\node_modules\auth0-js\src\index.js:1
(function (exports, require, module, __filename, __dirname) { import
Authentication from './authentication';
^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:670:28)
at Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Object.require.extensions.(anonymous function) [as .js]
(C:\Users\mfonpah\Documents\projects\nexus-web-client\web-
client\node_modules\babel-register\lib\node.js:152:7)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
any ideas on how to fix this?
thanks
If you see this error, your EF6 import statements are not being transpiled. Make sure your babel presets contain "env"
.babelrc and "babel" property in package.json
{
"presets":["env", "react"]
}
Depending on your use case you might also need to add the transform-es2015-modules-amd plugin, more here.
The full error is:
SyntaxError: /root/anon/config.json: Unexpected token ]
at Object.parse (native)
at Object.Module._extensions..json (module.js:425:27)
at Module.load (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at loadJson (/root/anon/anon.coffee:63:3)
at getConfig (/root/anon/anon.coffee:51:12)
at main (/root/anon/anon.coffee:136:12)
at Object.<anonymous> (/root/anon/anon.coffee:147:3)
at Object.<anonymous> (/root/anon/anon.coffee:3:1)
at Module._compile (module.js:410:26)
at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:173:23)
at compileScript (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:224:29)
at compilePath (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:174:14)
at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:98:20)
at Object.<anonymous> (/usr/local/lib/node_modules/coffee-script/bin/coffee:7:41)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
The code I'm working with is:
https://pastebin.com/pVYwHpLc
(Don't worry, I changed the keys.)
I'm confused what and where the error is (front end is my thing). Any help is appreciated.
Sorry to bother.
Although a bit late answer, the error is on line 12:
"204.97.104.30",
You should delete the comma character (,) to have a valid JSON
I am working on a mean.io application. I am trying to run this application on Ubuntu shell with forever module of node but it is throwing an error
"util.js:756
throw new TypeError('The super constructor to `inherits` must not ' +
^: The super constructor to `inherits` must not be null or undefined.
at Object.exports.inherits (util.js:756:11)
at Object.<anonymous> (/usr/lib/node_modules/forever/node_modules/forever-monitor/lib/forever-monitor/monitor.js:142:7)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/usr/lib/node_modules/forever/node_modules/forever-monitor/lib/index.js:14:24)
at Module._compile (module.js:435:26)
"
Can anyone help on this what is the actual issue,how i can resolve this error.
I have faced the same issue. It was due to using Redistore with "express" parameter
var RedisStore = require('connect-redis')(express);
finally I fixed it using a session as parameter.
var session = require('express-session');
var RedisStore = require('connect-redis')(session);
Hope it helps you.
I have the below sample code which is failing if i pass ISODate in JSON object
var data =[{"$match":{"CREATED_DATE":{"$gt":ISODate("2015-07-29T17:30:00.000Z"),"$lt":ISODate("2015-07-30T09:00:00.000Z")}}}]
var update=JSON.parse(data);
Below is the error
/home/ubuntu/rr.js:1
name) { var data =[{"$match":{"EPS_TRANSACTION.CREATED_DATE":{"$gt":ISODate("2
^
ReferenceError: ISODate is not defined
at Object.<anonymous> (/home/ubuntu/rr.js:1:123)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
I am unable to handle the error,any solution will be much helpful