cancel
Showing results for 
Search instead for 
Did you mean: 

Type mismatch: expected String but was Map (line 8, column 5 (offset: 335)) " {csvline:csvline}"

Sonylab
Node
i am still new to neo4j, so i am trying to load this csv file and i want to be able to get the same result as when I use the foreach clause but using apoc functions, although I am still learning the apoc functions,  meanwhile using the foreach clause works very fine, but upon using the apoc function I get this error!   
"Type mismatch: expected String but was Map (line 8, column 5 (offset: 335)) " {csvline:csvline}"
 
can some one please help me out ? thanks in advance ~!!
 
foreach:
   
    :auto using periodic commit
    load csv with headers from 'file:///E_Directory_Export.csv' as csvline fieldterminator ';'
    with csvline
    foreach (IgnoreMe in (CASE when csvline.Team is null  then [] else  [1] end) |
    merge (team: c_team  {identifier: csvline.Team})
    set team.name = csvline.Team
    )
 
 
 
can someone please tell me what I am doing wrong here, 
 
     :auto using periodic commit
    load csv with headers from 'file:///E_Directory_Export.csv' as csvline fieldterminator ';'
    with csvline
    optional match (team: c_team  {identifier: csvline.Team})
    CALL apoc.do.when(csvline.Team is NULL,
    'merge (team: c_team  {identifier: "csvline.Team"})
    set team.name = csvline.Team RETURN team',
    {csvline:csvline}
    ) YIELD value
    RETURN value.team as team ;
2 ACCEPTED SOLUTIONS

Why are you trying to use the apoc procedures? For what you want you can just use CALL IN TRANSACTIONS 

And for the fallback to "csvline.Team" you can use coalesce(csvLine.Team, "default-value")

Is your file really so large that you need separate transactions?

In apoc.do.when the third parameter is a string for the elseQuery not for the params map

https://neo4j.com/labs/apoc/4.4/overview/apoc.do/apoc.do.when/

 

View solution in original post

glilienfield
Ninja
Ninja

The value of 'csvline' is a map, not a string.  'csvline' is the entire row from the 'load csv', which is a map. Break out the individual keys from the map that you want to send to the query.


Also, you only have one cypher statement. The procedures requires one for when the conditions is 'true' and 'false'. Your map is specified in the third argument, which is supposed to be a string representing the 'else' cypher statement. 

Since you don't have an if/else scenario, it may be easier to use a call subquery as follows:

 

:auto load csv with headers from 'file:///E_Directory_Export.csv' as csvline fieldterminator ';'
call {
    with csvline
    with csvline
    where csvline.team is not null
    merge (team: c_team  {identifier: csvline.Team})
    set team.name = csvline.Team
} in transactions of 1000 rows

 

View solution in original post

2 REPLIES 2

Why are you trying to use the apoc procedures? For what you want you can just use CALL IN TRANSACTIONS 

And for the fallback to "csvline.Team" you can use coalesce(csvLine.Team, "default-value")

Is your file really so large that you need separate transactions?

In apoc.do.when the third parameter is a string for the elseQuery not for the params map

https://neo4j.com/labs/apoc/4.4/overview/apoc.do/apoc.do.when/

 

glilienfield
Ninja
Ninja

The value of 'csvline' is a map, not a string.  'csvline' is the entire row from the 'load csv', which is a map. Break out the individual keys from the map that you want to send to the query.


Also, you only have one cypher statement. The procedures requires one for when the conditions is 'true' and 'false'. Your map is specified in the third argument, which is supposed to be a string representing the 'else' cypher statement. 

Since you don't have an if/else scenario, it may be easier to use a call subquery as follows:

 

:auto load csv with headers from 'file:///E_Directory_Export.csv' as csvline fieldterminator ';'
call {
    with csvline
    with csvline
    where csvline.team is not null
    merge (team: c_team  {identifier: csvline.Team})
    set team.name = csvline.Team
} in transactions of 1000 rows