# Importing Triples from CSV files

**URL:** <https://community.neo4j.com/t/importing-triples-from-csv-files/23221>\
**Category:** Neo4j Graph Platform\
**Tags:** apoc, cypher, relationship, import\
**Created:** [August 10, 2020, 5:09pm UTC](https://community.neo4j.com/t/importing-triples-from-csv-files/23221 "2020-08-10T17:09:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikosphere](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/nikosphere/32/12011_2.png) [@nikosphere](https://community.neo4j.com/u/nikosphere)\
**Post date:** [August 10, 2020, 5:09pm UTC](https://community.neo4j.com/t/importing-triples-from-csv-files/23221/1 "2020-08-10T17:09:51Z")

</div>

Currently conducting a project on crime and I am not entirely sure how to go about this.

Currently, the only way I have learned to import is utilizing multiple csv files to create a graph. However, I end up being limited by the relationship being created. I do not want to make 10 different relationship csv files.

My data format in my csv is currently as follows:  
Columns 1 through 3:  
**node\_id, node\_label, entity\_value**

Columns 4 through 6  
**source, relationship,destination**

An example two full rows of the csv file:  
id, label, entity\_value, src, relationship, dst  
FBI, GovOrg, FBI, FBI, INVESTIGATED, FI1  
FI1, FinancialInstitution, Fin Inst#1, FI1, CASH\_DEALINGS, P12

I have also attached a csv file underneath as well with three samples.

The idea is that each node is created as such

```auto
CREATE {:Label {entity_value: entity_value, id:id}}

```

Then the relationships are just created with the IDs, merging uniquely so that there are not any duplicates on import.  
Please keep the following things in mind:

Neo4j Version: 4.1  
Libraries Used: APOC, Graph Data Science Library

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [August 10, 2020, 6:54pm UTC](https://community.neo4j.com/t/importing-triples-from-csv-files/23221/2 "2020-08-10T18:54:08Z")

</div>

```auto
One problem I see is the empty space after comma both in the headers and data rows. Enclosing headers and data columns with the back tic will solve this. 
Example: entity_value: lTrim(row.`entity_value`)

```
