cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Import csv file in javascript error

Novice
Node Link

Hello,
I try import csv file in javascript, but failed.

step1. Create Local database in neo4jtool
2X_d_dd48221428b9028940345ae4efe8b4ea7ac1da10.png

step2. write in javascript

const neo4j = require("neo4j-driver");
  const driver = neo4j.driver("bolt://localhost:7687", neo4j.auth.basic("TestGraph", "1234"),{encrypted: true});
  const session = driver.session();
  const start = new Date();
  let isDoneSession = session
    .run('Load csv with headers from "Datas/testtes2t.csv" as attackgraph create(a1:AttackGraph {attack_no: attackgraph.attack_no, attack_seq: attackgraph.attack_seq, from_id: attackgraph.from_id})', {limit: neo4j.int(5000)})
    .then(function (result) {
      const links = result.records.map(r => { return {source:r.get('source').toNumber(), target:r.get('target').toNumber()}});
      session.close();
      const ids = new Set();
      links.forEach(
        l => {ids.add(l.source);ids.add(l.target);}
      );
      var gData = { nodes: Array.from(ids).map(id => {return {id}}), links: links};
      const Graph = ForceGraph3D()(document.getElementById('MyIndexRenderers')).graphData(gData);
    })
    .catch(function (error) {
      console.log("Error!!!!!!!");
    });

step3. failed.....

browser-channel.js:60 WebSocket connection to 'wss://localhost:7687/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

why this happened?
please help me.
Thank you.

2 REPLIES 2

The default user name is neo4j not TestGraph

you have to put the csv file into the import folder of your database and then use file:///name.csv

Best take the import training

Thank you,
It was nice. have a nice day !