Loading Large CSV file #708
-
Hello, my name is Dag and I have a question regarding using the .net driver to load The query is executed using the _session.RunAsync(query, parameters); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @dagheggelund, sorry about the delay, I didn't notice you opened a discussion instead of an issue. You execute the query using Session.RunAsync:
You say it sometimes fails, without throwing any exceptions.
I'd expect it look a little something like: async Task ImportFileAsync(string file, IDriver driver, string database)
{
await using IAsyncSession session = driver.AsyncSession(x =>
x.WithDatabase(database)
.WithDefaultAccessMode(AccessMode.Write));
const string query = @"
LOAD CSV WITH HEADERS FROM $file AS row
MATCH (from:{fromLink} {{id: row.FromID}})
MATCH (to:{toLink} {{id: row.ToID}})
MERGE (from)-[:{predicate}]->(to)";
IResultCursor cursor = await session.RunAsync(query, new { file });
await cursor.ConsumeAsync();
} API Docs for IResultCursor.ConsumeAsync Your second question states that when it fails and does throw an exception that the file name it This very much makes me think you are having issues with your sessions, note that sessions must be used in a thread safe fashion and make no effort to protect against misuse. Opening & closing sessions is very cheap so it is best to avoid reusing them. If you have any further questions please let me know. |
Beta Was this translation helpful? Give feedback.
Hi @dagheggelund, sorry about the delay, I didn't notice you opened a discussion instead of an issue.
You execute the query using Session.RunAsync:
You say it sometimes fails, without throwing any exceptions.
I have a few questions:
I'd expect it look a little something like: