Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-05-2020 07:33 AM
Hi! We are trying to receive a CSV file from frontend and create nodes from the CSV content. How do we get the neo4J to load the CSV code from javascript automatically when we receive a new CSV-file?
Currently we are thinking something like this to receive the file in frontend:
import fileUpload from "express-fileupload";
app.use(fileUpload());
//Upload endpoint
app.post('/upload', (req, res) => {
if(req.files === null){
return res.status(400).json({ msg: 'No file uploaded'});
}
const file = req.files.file;
file.mv(${__dirname}/client/public/uploads/${file.name}, err => {
if(err){
console.error();
return res.status(500).send(err);
}
res.json({ fileName: file.name, filePath: `/uploads/${file.name}`});
})
})
Solved! Go to Solution.
05-05-2020 10:11 AM
You'll need to trigger a Cypher command, somehow. That could be an API method you add to Neo4j via a plugin. Though that's much trickier than you might think (I'm almost ready to publish an open plugin like this). Before you go too deep, check the import guide:
Your options:
$NEO_HOME/import
directory.The neo4j-javascript driver (docs) (github) can be used server-side, or client-side. There are two Cypher utilities that can import CSV:
However, both of these utilities require the file to already exist somewhere Neo can access.
If you're only building a javascript client, and you want the user to be able to create and upload the csv, then you're going to have to work some magic, and you have a few options:
05-05-2020 10:11 AM
You'll need to trigger a Cypher command, somehow. That could be an API method you add to Neo4j via a plugin. Though that's much trickier than you might think (I'm almost ready to publish an open plugin like this). Before you go too deep, check the import guide:
Your options:
$NEO_HOME/import
directory.The neo4j-javascript driver (docs) (github) can be used server-side, or client-side. There are two Cypher utilities that can import CSV:
However, both of these utilities require the file to already exist somewhere Neo can access.
If you're only building a javascript client, and you want the user to be able to create and upload the csv, then you're going to have to work some magic, and you have a few options:
05-06-2020 04:33 AM
We are thinking of the option:
Use a intermediary storage location, have the client send the CSV there, resulting in a URL that Neo4j can access, then run the Cypher import command through the neo4j-javascript driver.
and sessions would be the container that handles execution of cypher-queries into Neo4J when we drag and drop a CSV?
05-06-2020 07:31 PM
Hi, I think that an easy solution could be to create a cloud function (for example with Firebase). This function can be triggered when a file is uploaded to storage. This function receives the file, processes and creates the nodes in neo4j. The function will run in background.
https://firebase.google.com/docs/functions/gcp-storage-events
All the sessions of the conference are now available online