jexp / fincen

ICIJ #Fincen Files in Neo4j
https://www.icij.org/investigations/fincen-files/
32 stars 10 forks source link

apoc error when using finch_csv.cypher #1

Closed agmiller closed 4 years ago

agmiller commented 4 years ago

Screenshot 2020-09-22 at 12 00 06 PM

Please advise how to fix and what versions you are using that are known to work.

Thank you Kind Regards AGM

nrouyer commented 4 years ago

@agmiller same error observed with Neo4j 4.1.2. What worked for me on neo4j aura was to use apoc.date.format(apoc.date.parse(f.end_date, 'ms', 'MMM dd, yyyy'), 'ms', 'yyyy-MM-dd'):

match (f:Filing)
set f.transactions = toInteger(f.number_transactions)
set f.amount = toFloat(f.amount_transactions)
set f.end=apoc.date.format(apoc.date.parse(f.end_date, 'ms', 'MMM dd, yyyy'), 'ms', 'yyyy-MM-dd')
set f.begin=apoc.date.format(apoc.date.parse(f.begin_date, 'ms', 'MMM dd, yyyy'), 'ms', 'yyyy-MM-dd')
merge (ben:Entity {id:f.beneficiary_bank_id})
on create set ben.name = f.beneficiary_bank, ben.location = point({latitude:toFloat(f.beneficiary_lat), longitude:toFloat(f.beneficiary_lng)})
merge (cben:Country {code:f.beneficiary_iso})
merge (ben)-[:COUNTRY]->(cben)
merge (f)-[:BENEFITS]->(ben)
merge (filer:Entity {id:f.filer_org_name_id})
on create set filer.name = f.filer_org_name, filer.location = point({latitude:toFloat(f.filer_org_lat), longitude:toFloat(f.filer_org_lng)})
merge (f)<-[:FILED]-(filer)
merge (org:Entity {id:f.originator_bank_id})
on create set org.name = f.originator_bank, org.location = point({latitude:toFloat(f.origin_lat), longitude:toFloat(f.origin_lng)})
merge (corg:Country {code:f.originator_iso})
merge (org)-[:COUNTRY]->(corg)
merge (f)-[:ORIGINATOR]->(org)

But it does not work on Neo4j 4.1.2...

jexp commented 4 years ago

Sorry for that, I also didn't get a notification about the issue, which is odd.

I just forgot the git push after the twitch stream. Done now.

ghost commented 2 years ago

I'm trying to import fincen_csv.cypher with Neo4j Browser version: 4.3.5 on Neo4j Server version: 4.3.7 (community) but I get the following error:

Neo.ClientError.Statement.SyntaxError: Unknown function 'apoc.date.parse' (line 4, column 48 (offset: 164))
"SET (`f`).`end` = `date`((`datetime`(({`epochSeconds`: `coalesce`((`apoc`.`date`.`parse`(((`f`).`end_date`), ("s"), ("MMM dd, yyyy"))), (0))}))))"
            ^
ghost commented 2 years ago

Sorry to bother. Seems to successfully import now apart form the last line which I guess is just a comment:

Neo.ClientError.Statement.SyntaxError: Unexpected end of input: expected whitespace, comment, CYPHER options, EXPLAIN, PROFILE or Query (line 8, column 3 (offset: 823))
"*/"
   ^

I had to start neo4j with apoc installed for it to work:

docker run \
    --name testneo4j \
    -p7474:7474 -p7687:7687 \
    -d \
    -v $HOME/neo4j/data:/data \
    -v $HOME/neo4j/logs:/logs \
    -v $HOME/neo4j/import:/var/lib/neo4j/import \
    -v $HOME/neo4j/plugins:/plugins \
    --env NEO4J_AUTH=neo4j/test \
    -e NEO4J_apoc_export_file_enabled=true \
    -e NEO4J_apoc_import_file_enabled=true \
    -e NEO4J_apoc_import_file_use__neo4j__config=true \
    -e NEO4JLABS_PLUGINS=\[\"apoc\"\] \
    neo4j:latest