cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Need help correcting a query

LOAD CSV WITH HEADERS FROM
'https://github.com/aravind-sundaresan/Graph-ML-Fraud-Detection/blob/master/data/bs140513_032310.csv' AS line
WITH line,
SPLIT(line.customer, "'") AS customerID,
SPLIT(line.merchant, "'") AS merchantID,
SPLIT(line.age, "'") AS customerAge,
SPLIT(line.gender, "'") AS customerGender,
SPLIT(line.zipcodeOri, "'") AS customerZip,
SPLIT(line.zipMerchant, "'") AS merchantZip,
SPLIT(line.category, "'") AS transCategory

I am getting this error:

Query cannot conclude with WITH (must be RETURN or an update clause) (line 3, column 1 (offset: 137))
"WITH line,"

What is wrong with it?

I need to load above csv and then split it and then change the column names

6 REPLIES 6

Hi,
as the error saying, you are missing a RETURN statement.
So add for example at the end of the query

RETURN *

That didn't work,

now I am getting this:

Couldn't load the external resource at: https://github.com/aravind-sundaresan/Graph-ML-Fraud-Detection/blob/master/data/bs140513_032310.csv 1

Also, if you could help me with replacement of following queries as the library has been deprecated:

Execute the following query to run the PageRank algorith on the placeholder enteties:

CALL algo.pageRank('Placeholder', 'Payes', {writeProperty: 'pagerank'})

Run this for community mining through label propagation:

CALL algo.labelPropagation('Placeholder', 'Payes', 'OUTGOING',
 {write:true, partitionProperty: "community", weightProperty: "count"})

And lastly, the following for degree:

MATCH (p:Placeholder)
SET p.degree = apoc.node.degree(p, 'Payes')

It's strange, because I managed successfully to run it jus by adding this line:

RETURN *

Not sure why but I am still getting error with the same query.

Also , can you address the later part of the query as it is more important to me.

I was able to load the file using following:

:auto USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM
'https://github.com/aravind-sundaresan/Graph-ML-Fraud-Detection/blob/master/data/bs140513_032310.csv' AS line
MERGE (customer:Customer {id: 'customer', age: 'age', gender:'gender', customerZip:'line.zipcodeOri'}) 
MERGE (merchant:Merchant {id: 'merchant', zipCode: 'zipMerchant'})
CREATE (transaction:Transaction {amount: toInteger(line.amount), fraud: line.fraud, category: toInteger(line.category)})-[:WITH]->(merchant)
CREATE (customer)-[:MAKE]->(transaction);

Now, I need replacement of these queries as the previous library has been deprecated:

Execute the following query to run the PageRank algorith on the placeholder enteties:

CALL algo.pageRank('Placeholder', 'Payes', {writeProperty: 'pagerank'})

Run this for community mining through label propagation:

CALL algo.labelPropagation('Placeholder', 'Payes', 'OUTGOING',
 {write:true, partitionProperty: "community", weightProperty: "count"})

And lastly, the following for degree:

MATCH (p:Placeholder)
SET p.degree = apoc.node.degree(p, 'Payes')

Once this is sorted, I have one final thing to ask where I am stuck. Is there any way we can connect on video chat or audio chat?

@harsh.solanki see the following code:

LOAD CSV WITH HEADERS FROM 'https://github.com/aravind-sundaresan/Graph-ML-Fraud-Detection/blob/master/data/bs140513_032310.csv' AS line
CREATE (:Customer {
	name: line.customer,
	name: line.merchant,
	name: line.age,
	name: line.gender,
	name: line.zipcodeOri,
	name: line.zipMerchant,
	name: line.category
    })
RETURN line.customer AS customerID, line.merchant AS merchantID, line.age AS customerAge,  line.gender AS customerGender,  line.zipcodeOri AS customerZip,  line.zipMerchant AS merchantZip,  line.category AS transCategory

Hey Boris,

Can you help me with following. the data is now loaded correctly but following algos are not working for me:

Execute the following query to run the PageRank algorith on the placeholder enteties:

CALL algo.pageRank('Placeholder', 'Payes', {writeProperty: 'pagerank'})

Run this for community mining through label propagation:

CALL algo.labelPropagation('Placeholder', 'Payes', 'OUTGOING',
 {write:true, partitionProperty: "community", weightProperty: "count"})

I keep getting following error: There is no procedure with the name algo.pageRank registered for this database instance. Please ensure you've spelled the procedure name correctly and that the procedure is properly deployed.

These are the queries I ran prior to this:

CREATE CONSTRAINT ON (c:Customer) ASSERT c.id IS UNIQUE; CREATE CONSTRAINT ON (b:Bank) ASSERT b.id IS UNIQUE;

USING PERIODIC COMMIT LOAD CSV WITH HEADERS FROM 'file:///data.csv' AS line WITH line, SPLIT(line.customer, "'") AS customerID, SPLIT(line.merchant, "'") AS merchantID, SPLIT(line.age, "'") AS customerAge, SPLIT(line.gender, "'") AS customerGender, SPLIT(line.zipcodeOri, "'") AS customerZip, SPLIT(line.zipMerchant, "'") AS merchantZip, SPLIT(line.category, "'") AS transCategory

MERGE (customer:Customer {id: customerID[1], age: customerAge[1], gender: customerGender[1], zipCode: customerZip[1]})

MERGE (bank:Bank {id: merchantID[1], zipCode: merchantZip[1]})

CREATE (transaction:Transaction {amount: line.amount, fraud: line.fraud, category: transCategory[1], step: line.step})-[:WITH]->(bank) CREATE (customer)-[:MAKE]->(transaction);

*** Create Relationships using below query ***

MATCH (c1:Customer)-[:MAKE]->(t1:Transaction)-[:WITH]->(b1:Bank) WITH c1, b1 MERGE (p1:Placeholder {id: b1.id})

MATCH (c1:Customer)-[:MAKE]->(t1:Transaction)-[:WITH]->(b1:Bank) WITH c1, b1 MERGE (p1:Placeholder {id: c1.id})

MATCH (c1:Customer)-[:MAKE]->(t1:Transaction)-[:WITH]->(b1:Bank) WITH c1, b1, count(*) as cnt MATCH (p1:Placeholder {id:c1.id}) WITH c1, b1, p1, cnt MATCH (p2:Placeholder {id: b1.id}) WITH c1, b1, p1, p2, cnt CREATE (p1)-[:Payes {cnt: cnt}]->(p2)