# How to avoid error while loading a large CSV

**URL:** <https://community.neo4j.com/t/how-to-avoid-error-while-loading-a-large-csv/56052>\
**Category:** Cypher\
**Tags:** apoc, cypher, import\
**Created:** [May 9, 2022, 2:56pm UTC](https://community.neo4j.com/t/how-to-avoid-error-while-loading-a-large-csv/56052 "2022-05-09T14:56:32Z")\
**Posts on this page:** 3\
**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:** [May 9, 2022, 2:56pm UTC](https://community.neo4j.com/t/how-to-avoid-error-while-loading-a-large-csv/56052/1 "2022-05-09T14:56:32Z")

</div>

Neo4j server Community edition 4.4.6 , running on Ubuntu 20.04

Well, I've just solved a big problem, being able to load a quite large number of transactions using `LOAD CSV`.

I dumped a table from `Postgres`, a table running fine without problems, but when I go to LOAD into neo4j it returns me some errors. Often, there is only an unpaired `'` or `"` or a spare `\n`.

As they are millions rows, It's really difficult to understand where the errors are hidden, expecially because neo4j returns the `offending position` and rot the `offending row`.

I created a shell script to `split` the input file in chunks of `10.000` rows and then executing a `CALL {} IN TRANSACTION OF 5000 rows`, in this way, if I find an error, I loose only 10.000 rows and not all the millions.

I think should be nice if the `LOAD CSV` shoul be able to reject in an `error.log` the offending lines, without stopping its run.

Anyway has an idea?

Thank you

---

<div class="post-metadata">

**Author:** ![gskrishnareddy5](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/gskrishnareddy5/32/23021_2.png) [@gskrishnareddy5](https://community.neo4j.com/u/gskrishnareddy5)\
**Post date:** [May 17, 2022, 12:14pm UTC](https://community.neo4j.com/t/how-to-avoid-error-while-loading-a-large-csv/56052/2 "2022-05-17T12:14:50Z")

</div>

Please try with apoc.load.csv function available in Neo4j. to use this 1st we need to add apoc plugin.

CALL apoc.load.csv("MY\_CSV\_URL", {failOnError:false})  
YIELD list, map  
WITH list, map  
call apoc.do.when(list = , "return 'nothingToList' as list, 'nothingToMap' as map", "return list, map", {list: list, map: map})  
YIELD value  
RETURN value["list"], value["map"]

---

<div class="post-metadata">

**Author:** ![gskrishnareddy5](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/gskrishnareddy5/32/23021_2.png) [@gskrishnareddy5](https://community.neo4j.com/u/gskrishnareddy5)\
**Post date:** [May 17, 2022, 12:15pm UTC](https://community.neo4j.com/t/how-to-avoid-error-while-loading-a-large-csv/56052/3 "2022-05-17T12:15:34Z")

</div>

for more info you can refer below

> **[Load CSV - APOC Extended Documentation](https://neo4j.com/labs/apoc/4.3/import/load-csv/)**
>
> This section describes procedures that can be used to import data from CSV files.
