# A probable error while using LOAD CSV

**URL:** https://community.neo4j.com/t/a-probable-error-while-using-load-csv/60268
**Category:** Neo4j Graph Platform
**Tags:** migrated
**Created:** [June 6, 2022, 2:35pm UTC](https://community.neo4j.com/t/a-probable-error-while-using-load-csv/60268 "2022-06-06T14:35:38Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)
#### Post date: [June 6, 2022, 2:35pm UTC](https://community.neo4j.com/t/a-probable-error-while-using-load-csv/60268/1 "2022-06-06T14:35:38Z")

</div>

I'm running a community edition 4.4.7

I'm importing some data using `LOAD CSV`.

The functions ``linenumber()` and `file()` runs only outside `apoc.do.when` but return `null` if used inside.

The following statement doesn't run:

```auto
call apoc.do.when(x IS NULL,
    'MERGE (error:Error)
     MERGE (node)-[h:HAS_ERROR]->(error)
       SET h.linenumber = linenumber(),
           h.file = file()
     RETURN 0',
    'RETURN 1,
    { node:node } YIELD value

```

While this one runs:

```auto
WITH l as linenumber(), f as file()

call apoc.do.when(x IS NULL,
    'MERGE (error:Error)
     MERGE (node)-[h:HAS_ERROR]->(error)
       SET h.linenumber = l,
           h.file = f
     RETURN 0',
    'RETURN 1,
    { l:l, f:f, node:node } YIELD value

```

I find it a big nuisance!

Can someone confirm and/or explain why? As these two are the only function specific to `LOAD CSV` maybe they could be imported into all the apoc functions!

---

<div class="post-metadata">

### Author: ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)
#### Post date: [June 6, 2022, 2:51pm UTC](https://community.neo4j.com/t/a-probable-error-while-using-load-csv/60268/2 "2022-06-06T14:51:34Z")

</div>

That make sense to me, as the cypher in the do.when is passed to a custom procedure on the server to run. It does not have access to the scope outside the do.when clause. The ability to pass parameters in the do.when clause is used to pass these values from the outer scope to the custom procedure.

---

<div class="post-metadata">

### Author: ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)
#### Post date: [June 6, 2022, 3:04pm UTC](https://community.neo4j.com/t/a-probable-error-while-using-load-csv/60268/3 "2022-06-06T15:04:57Z")

</div>

Do you know any way to edit a post after posting in this new version of the community? It look like if you publish, you can never make any correction!

---

<div class="post-metadata">

### Author: ![paolodipietro58](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paolodipietro58/32/21045_2.png) [@paolodipietro58](https://community.neo4j.com/u/paolodipietro58)
#### Post date: [June 6, 2022, 3:03pm UTC](https://community.neo4j.com/t/a-probable-error-while-using-load-csv/60268/4 "2022-06-06T15:03:42Z")

</div>

I agree with you: technically it makes sense. But it is an annoying limit.

As we've already seen in another post, apoc will automatically add variables when not explicit declared.  
And, as there are only these two functions, apoc could add them to the set of the known values when running a custom procedure. It will allow users to spare a lot of writing!

---

<div class="post-metadata">

### Author: ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)
#### Post date: [June 6, 2022, 3:41pm UTC](https://community.neo4j.com/t/a-probable-error-while-using-load-csv/60268/5 "2022-06-06T15:41:09Z")

</div>

If you are referring to your prior post, what happened there is the apoc procedure was adding the passed parameters as cypher variables, as well as making them available as parameters. It did not automatically add the outer scope variables to the procedure's scope; you still needed to pass what you wanted as apoc procedure parameters.

---

<div class="post-metadata">

### Author: ![glilienfield](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/glilienfield/32/27534_2.png) [@glilienfield](https://community.neo4j.com/u/glilienfield)
#### Post date: [June 6, 2022, 3:38pm UTC](https://community.neo4j.com/t/a-probable-error-while-using-load-csv/60268/6 "2022-06-06T15:38:32Z")

</div>

I have only got edit to work on my iPhone, not on my Mac laptop. I use Safari on both. Another difference, is the edit on the phone does not have the ellipse option in the icon bar above, so you can select to add code on iPhone, but work on Mac laptop.
